public void Basic(string[] args, AssertBasic assert) { CommanderParser <Basic> p = new CommanderParser <Basic>(); Basic b = p.Parse(args); assert(b); }
public static async Task Main(string[] args) { var parser = new CommanderParser <Options>(); try { var options = parser.Parse(args); await RunAsync(options); } catch (ParameterMissingException) { Console.WriteLine(parser.Usage()); } }
static async Task Main(string[] args) { Console.WriteLine("BansheeBlog updater\n"); var parser = new CommanderParser <CommandLineArgs>(); Console.WriteLine(parser.Usage()); CommandLineArgs parsedArgs; try { parsedArgs = parser.Parse(); } catch (Exception e) { Console.WriteLine(e.Message); return; } if (parsedArgs.Check != null) { Console.WriteLine("Check is not yet supported"); } else if (parsedArgs.Install != null || parsedArgs.WaitAndInstall != null) { var wait = parsedArgs.WaitAndInstall != null; var installArgs = wait ? parsedArgs.WaitAndInstall : parsedArgs.Install; var updateDir = installArgs.UpdateDirectory; var backendDir = installArgs.BackendDirectory; var publicDir = installArgs.PublicDirectory; if (!Directory.Exists(updateDir) || !Directory.Exists(backendDir) || !Directory.Exists(publicDir)) { Console.WriteLine("One or more of the required directories does not exist"); return; } if (wait) { Console.WriteLine("Waiting for BansheeBlog to exit..."); await AwaitServerShutdown(backendDir); } try { Console.WriteLine("Deleting backend server files"); File.Delete(Path.Combine(backendDir, "BansheeBlog.dll")); // Main file first to ensure it is closed DeleteBackendServerFiles(backendDir); Console.WriteLine("Deleting admin frontend files"); DeleteAdminFrontendFiles(publicDir); Console.WriteLine("Installing updated backend server files"); MoveBackendServerFiles(updateDir, backendDir); Console.WriteLine("Installing updated admin frontend files"); MoveAdminFrontendFiles(updateDir, publicDir); Console.WriteLine("Cleaning up after update"); Cleanup(updateDir); if (wait) { Console.WriteLine("Starting BansheeBlog"); StartServer(backendDir); } Console.WriteLine("\nDone! This updater closes in 3 seconds, bye :)"); await Task.Delay(3000); } catch (Exception e) { Console.WriteLine("Blast!"); Console.WriteLine(e.Message); } } }
public bool SetParam(string[] args, string config_path) { CommanderParser <Args> parser = new CommanderParser <Args>(); try { instance = parser.Add(args).Parse(); } catch (System.Exception e) { Logger.Error(e.Message); return(false); } if (instance.version) { Console.WriteLine(Version); return(false); } string config_filename = instance.config_file.IsNotNullOrEmpty() ? instance.config_file : config_path; if (!Config.Instance.Initialize(config_filename)) { Logger.Error( string.Format("Failed to initialize config. please check config : {0} file", config_path)); return(false); } #region Wallet prefix if (Config.Instance.Net.Type.Equals("mainnet")) { // TODO : Wallet address prefix mainnet } else { // TODO : Wallet address prefix testnet } #endregion #region Local witness if (instance.privatekey.Length > 0) { instance.LocalWitness = new LocalWitness(instance.privatekey.HexToBytes()); if (!string.IsNullOrEmpty(instance.witness_address)) { byte[] address = Wallet.Base58ToAddress(instance.witness_address); if (address.IsNotNullOrEmpty()) { instance.LocalWitness.SetWitnessAccountAddress(address); Logger.Debug("local witness account address from command."); } else { instance.witness_address = ""; Logger.Warning("Local witness account address is incorrect."); } } instance.LocalWitness.InitWitnessAccountAddress(); } else if (Config.Instance.LocalWitness != null && Config.Instance.LocalWitness.LocalWitness != null && Utils.CollectionUtil.IsNotNullOrEmpty(Config.Instance.LocalWitness.LocalWitness)) { instance.LocalWitness = new LocalWitness(); List <byte[]> witness_list = Config.Instance.LocalWitness.LocalWitness; if (witness_list.Count > 1) { Logger.Warning("Local witness count must be one. get the first witness"); witness_list = witness_list.GetRange(0, 1); } instance.LocalWitness.SetPrivateKeys(witness_list); if (Config.Instance.LocalWitness.LocalWitnessAccountAddress.IsNotNullOrEmpty()) { byte[] address = Wallet.Base58ToAddress(Config.Instance.LocalWitness.LocalWitnessAccountAddress); if (address.IsNotNullOrEmpty()) { instance.LocalWitness.SetWitnessAccountAddress(address); Logger.Debug("Local witness account address from \'config.conf\' file."); } else { Logger.Warning("Local witness account address is incorrect."); } } instance.LocalWitness.InitWitnessAccountAddress(); } else if (Config.Instance.LocalWitness != null && Config.Instance.LocalWitness.LocalWitnessKeyStore != null && Utils.CollectionUtil.IsNotNullOrEmpty(Config.Instance.LocalWitness.LocalWitnessKeyStore)) { List <byte[]> privatekeys = new List <byte[]>(); instance.LocalWitness = new LocalWitness(); if (instance.witness) { // TODO : Keystore 로드 CLI와 함께 정리해서 중복제거 if (Config.Instance.LocalWitness.LocalWitnessKeyStore.Count > 0) { string file_path = Config.Instance.LocalWitness.LocalWitnessKeyStore[0]; JObject json; using (var file = File.OpenText(file_path)) { string data = file.ReadToEnd(); json = JObject.Parse(data); } string password = CommandLineUtil.ReadPasswordString("Password: "******"Invalid password." ); } KeyStore keystore = new KeyStore(); keystore = JsonConvert.DeserializeObject <KeyStore>(json.ToString()); if (!KeyStoreService.DecryptKeyStore(password, keystore, out byte[] privatekey))