public CsvViewer(CommandLine.CommandLine cmd, FileIO fio, Ui ui, Formatieren format) { _cmd = cmd; _fio = fio; _ui = ui; _format = format; }
public void RunApplication(string[] args) { var commandLine = new CommandLine(); commandLine.Parse(args); using (var @lock = CreateLock(string.IsNullOrEmpty(commandLine.LockName) ? @"F17BFCF1-0832-4575-9C7D-F30D8C359159" : commandLine.LockName, commandLine.AddGlobalPrefix)) { Console.WriteLine("Acquiring lock"); @lock.Lock(); Console.WriteLine("Acquired lock"); try { Console.WriteLine("Holding lock for {0} seconds", commandLine.HoldTime); Thread.Sleep(1000*commandLine.HoldTime); } finally { Console.WriteLine("Released lock"); @lock.Unlock(); } } Console.WriteLine("Press any key to exit..."); Console.ReadKey(true); }
static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); if (LoadConfiguration(args)) { Configuration.Environment = ExecutionEnvironment.WindowsApplication; ICommandLine commandLine = new CommandLine(args); string titleArgument = commandLine.GetArgument("title"); string projectPath = commandLine.GetArgument("project"); string viewName = commandLine.GetArgument("view"); string recordId = commandLine.GetArgument("record"); try { Epi.Windows.Enter.EnterMainForm mainForm = new Epi.Windows.Enter.EnterMainForm(); if (!mainForm.IsDisposed) { mainForm.Show(); if (mainForm.WindowState == FormWindowState.Minimized) { mainForm.WindowState = FormWindowState.Normal; } mainForm.Activate(); mainForm.Text = string.IsNullOrEmpty(titleArgument) ? mainForm.Text : titleArgument; if (!string.IsNullOrEmpty(projectPath)) { Project project = new Project(projectPath); mainForm.CurrentProject = project; if (string.IsNullOrEmpty(recordId)) { mainForm.FireOpenViewEvent(project.Views[viewName]); } else { mainForm.FireOpenViewEvent(project.Views[viewName], recordId); } } //--2225 Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); //-- System.Windows.Forms.Application.Run(mainForm); } mainForm = null; } catch (Exception baseException) { MsgBox.ShowError(string.Format("Error: \n {0}", baseException.ToString())); } } }
protected override void Initialise(CommandLine cl) { if (cl.args.Count == 1) volumeId = cl.args[0].Trim(); else throw new SyntaxException("The snapshot command requires one parameter"); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { var commandLine = new CommandLine(args); if (commandLine.RunAsService) { ServiceBase[] servicesToRun = new ServiceBase[] {new ShredHostService()}; ServiceBase.Run(servicesToRun); } else if (!String.IsNullOrEmpty(commandLine.PreviousExeConfigurationFilename)) { var groups = SettingsGroupDescriptor.ListInstalledLocalSettingsGroups(); foreach (var group in groups) SettingsMigrator.MigrateSharedSettings(group, commandLine.PreviousExeConfigurationFilename); ShredSettingsMigrator.MigrateAll(commandLine.PreviousExeConfigurationFilename); } else { Thread.CurrentThread.Name = "Main thread"; if (!ManifestVerification.Valid) Console.WriteLine("The manifest detected an invalid installation."); ShredHostService.InternalStart(); Console.WriteLine("Press <Enter> to terminate the ShredHost."); Console.WriteLine(); Console.ReadLine(); ShredHostService.InternalStop(); } }
public void Execute(CommandLine commandLine, CommandExecutionContext context) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("=================================================="); Console.WriteLine(" Welcome to {0} {1}", ApplicationInfo.Title, ApplicationInfo.Version.ToString(2)); Console.WriteLine(" " + ApplicationInfo.Description); Console.WriteLine(" " + ApplicationInfo.CopyrightHolder); Console.WriteLine("=================================================="); Console.ResetColor(); Console.WriteLine(); Console.WriteLine("Available commands are:"); foreach (var cmd in CommandFactory.All) { Console.Write("-" + cmd.Name); Console.Write("\t"); if (!String.IsNullOrEmpty(cmd.ShortName)) { Console.Write("[" + cmd.ShortName + "] "); } Console.Write(cmd.Description); if (!String.IsNullOrEmpty(cmd.Usage)) { Console.Write(" Usage: " + cmd.Usage); } Console.WriteLine(); } }
public void Execute(CommandLine commandLine, CommandExecutionContext context) { if (commandLine.Parameters.Count != 2) { ConsoleUtil.ErrorLine("Invalid request. Please check syntax: " + Usage); return; } var host = commandLine.Parameters[1]; var ip = commandLine.Parameters[0]; if (context.Hosts.Contains(host)) { if (commandLine.Options.Count > 0 && commandLine.Options[0].Name == "override") { context.Hosts.Set(ip, host); context.Hosts.Save(); Console.WriteLine("1 entry updated: " + commandLine.Parameters[0] + " " + commandLine.Parameters[1]); } else { ConsoleUtil.ErrorLine(host + " already exists. Use -override to override the existing entry."); } } else { context.Hosts.Set(commandLine.Parameters[0], commandLine.Parameters[1]); context.Hosts.Save(); Console.WriteLine("1 entry added: " + commandLine.Parameters[0] + " " + commandLine.Parameters[1]); } }
public override void CheckOptions(CommandLine cmd) { // Confidence estimator double confidence = Allcea.DEFAULT_CONFIDENCE; double sizeRel = Allcea.DEFAULT_RELATIVE_SIZE; double sizeAbs = Allcea.DEFAULT_ABSOLUTE_SIZE; if (cmd.HasOption('c')) { confidence = AbstractCommand.CheckConfidence(cmd.GetOptionValue('c')); } if (cmd.HasOption('s')) { string[] sizeStrings = cmd.GetOptionValues('s'); if (sizeStrings.Length != 2) { throw new ArgumentException("Must provide two target effect sizes: relative and absolute."); } sizeRel = AbstractCommand.CheckRelativeSize(sizeStrings[0]); sizeAbs = AbstractCommand.CheckAbsoluteSize(sizeStrings[1]); } this._confEstimator = new NormalConfidenceEstimator(confidence, sizeRel, sizeAbs); // Double format if (cmd.HasOption('d')) { this._decimalDigits = AbstractCommand.CheckDigits(cmd.GetOptionValue('d')); } // Files this._inputPath = AbstractCommand.CheckInputFile(cmd.GetOptionValue('i')); if (cmd.HasOption('j')) { this._judgedPath = AbstractCommand.CheckJudgedFile(cmd.GetOptionValue('j')); } this._estimatedPath = AbstractCommand.CheckEstimatedFile(cmd.GetOptionValue('e')); }
/// <summary> /// 获取用户命令。 /// </summary> /// <param name="args">命令行参数。</param> /// <param name="verb">命令代号。</param> /// <returns></returns> public static CommandLine GetCommand(string[] args, string verb) { CommandLine command = null; if (args != null && args.Length > 0) { if (verb.IndexOf('-') != 0) verb = "-" + verb; for (int i = 0; i < args.Length; i++) { if (args[i] == verb) { command = new CommandLine(verb, String.Empty); if (args[i + 1].IndexOf(("-")) != 0) { command.Parameter = args[i + 1]; } break; } } } return command; }
public static void Main(string[] args) { CommandLine commandLine = new CommandLine(args); switch(commandLine.Action) { case "new": // Create a new employee Console.WriteLine("'Creating' a new Employee."); break; case "update": // Update an existing employee's data Console.WriteLine("'Updating' a new Employee."); break; case "delete": // Remove an existing employee's file Console.WriteLine("'Removing' a new Employee."); break; default: Console.WriteLine( "Employee.exe new|update|delete " + "<id> [firstname] [lastname]"); break; } }
public void Run(string[] args) { CommandLine commandLine = new CommandLine(); commandLine.AddOption("Verbose", false, "-verbose"); commandLine.Parse(args); if ((bool)commandLine.GetOption("-h")) { commandLine.Help("Katahdin Interpreter"); return; } Runtime runtime = new Runtime(true, false, false, false, (bool)commandLine.GetOption("-verbose")); //new ConsoleParseTrace(runtime); runtime.SetUp(commandLine.Args); if (!((bool)commandLine.GetOption("-nostd"))) runtime.ImportStandard(); foreach (string file in commandLine.Files) runtime.Import(file); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { var commandLine = new CommandLine(args); if (commandLine.RunAsService) { var ServicesToRun = new ServiceBase[] { new ShredHostService() }; ServiceBase.Run(ServicesToRun); } else if (!String.IsNullOrEmpty(commandLine.PreviousExeConfigurationFilename)) { var groups = SettingsGroupDescriptor.ListInstalledLocalSettingsGroups(); groups.Add(new SettingsGroupDescriptor(typeof (ShredSettingsMigrator).Assembly.GetType("ClearCanvas.Server.ShredHost.ShredHostServiceSettings"))); foreach (var group in groups) SettingsMigrator.MigrateSharedSettings(group, commandLine.PreviousExeConfigurationFilename); ShredSettingsMigrator.MigrateAll(commandLine.PreviousExeConfigurationFilename); } else { ShredHostService.InternalStart(); Console.WriteLine("Press <Enter> to terminate the ShredHost."); Console.WriteLine(); Console.ReadLine(); ShredHostService.InternalStop(); } }
public static void CreateInstance(string commandName, CommandLine commandLine) { commandLine.command = CreateInstance(commandName); if (commandLine.command == null) throw new SyntaxException(string.Format("Unknown command: {0}", commandName)); else commandLine.command.Initialise(commandLine); }
public void RunApplication(string[] args) { var commandLine = new CommandLine(args); var groups = SettingsGroupDescriptor.ListInstalledLocalSettingsGroups(); foreach (var group in groups) SettingsMigrator.MigrateSharedSettings(group, commandLine.PreviousExeConfigurationFilename); }
protected override void Initialise(CommandLine cl) { if (cl.args.Count > 0) command = Command.CreateInstance(cl.args[0]); if (command == null) command = this; }
public void UpdateWorkingDirectory(string script) { var commandLine = new CommandLine(script); switch (CommandType(script)) { case CdCommand.Prompt: _workingDirectory = commandLine.Function.ToUpper() + "\\"; break; case CdCommand.Slash: _workingDirectory = WorkingDirectory.Substring(0, 3); break; case CdCommand.Regular: var args = commandLine.Arguments; if (args != null && args.Count > 0) { var arg = args.First(); if(arg.Contains(":")) { _workingDirectory = arg; } else { if (arg.Contains("..")) { var levels = Regex.Matches(arg, @"\.\.").Count; var segments = WorkingDirectory.Split('\\'); var argSegs = arg.Split('\\'); var trailingDirs = argSegs.SkipWhile(o => o.Equals("..")); var count = segments.Count(); var newLevels = count - levels; if (newLevels < 2) { _workingDirectory = segments.First() + "\\" + string.Join("\\", trailingDirs); } else { var newSegs = segments.Take(newLevels).ToList(); newSegs.AddRange(trailingDirs); _workingDirectory = string.Join("\\", newSegs); } } else { if (WorkingDirectory.EndsWith("\\")) { _workingDirectory = WorkingDirectory + arg; } else { _workingDirectory = WorkingDirectory + "\\" + arg; } } } } break; } }
static void Main(string[] args) { CommandLine commandLine = new CommandLine(args); switch(commandLine.Action) { // ... } }
public void commandLine_Contains_using_invalid_args_should_return_false() { var expected = false; var target = new CommandLine( new[] { "-data" } ); Boolean actual = target.Contains( "d" ); actual.Should().Be.EqualTo( expected ); }
public void commandLine_Contains_using_valid_args_should_return_true_ignoring_slash_arg_prefix() { var expected = true; var target = new CommandLine( new[] { "/d" } ); Boolean actual = target.Contains( "d" ); actual.Should().Be.EqualTo( expected ); }
public void commandLine_Contains_using_valid_args_should_ignore_casing() { var expected = true; var target = new CommandLine( new[] { "D" } ); Boolean actual = target.Contains( "d" ); actual.Should().Be.EqualTo( expected ); }
public void RunApplication(string[] args) { CommandLine commandLine = new CommandLine(args); foreach (SettingsGroupDescriptor group in SettingsGroupDescriptor.ListInstalledLocalSettingsGroups()) { Type type = Type.GetType(group.AssemblyQualifiedTypeName, true); var settings = ApplicationSettingsHelper.GetSettingsClassInstance(type); ApplicationSettingsExtensions.ImportSharedSettings(settings, commandLine.ConfigurationFilename); } }
public void commandLine_tryGetValue_using_empty_args_should_not_fail() { var expected = false; var target = new CommandLine( new String[ 0 ] ); Int32 v; Boolean actual = target.TryGetValue<Int32>( "xyz", out v ); actual.Should().Be.EqualTo( expected ); }
static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); if (LoadConfiguration()) { try { Configuration.Environment = ExecutionEnvironment.WindowsApplication; string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string executablePath = System.IO.Path.Combine(path, "EpiInfo.exe"); Epi.Windows.MakeView.Forms.MakeViewMainForm makeViewMainForm = new Epi.Windows.MakeView.Forms.MakeViewMainForm(); ICommandLine commandLine = new CommandLine(args); string titleArgument = commandLine.GetArgument("title"); string projectPath = commandLine.GetArgument("project"); string viewName = commandLine.GetArgument("view"); if (titleArgument != null) { makeViewMainForm.Text = titleArgument; } if (! string.IsNullOrEmpty(projectPath)) { makeViewMainForm.LoadViewFromCommandLine(projectPath, viewName); } else { if (!makeViewMainForm.IsDisposed) { makeViewMainForm.Show(); if (makeViewMainForm.WindowState == FormWindowState.Minimized) { makeViewMainForm.WindowState = FormWindowState.Normal; } makeViewMainForm.Activate(); } if (args.Length > 0 && args[0] is string && System.IO.File.Exists(args[0])) { makeViewMainForm.GetTemplate(args[0]); } } System.Windows.Forms.Application.Run(makeViewMainForm); makeViewMainForm = null; } catch(Exception ex) { MsgBox.ShowException(ex); } } }
public static void Main(string[] args) { try { // Parse command line arguments s_commandLine = new CommandLine(args); if (!s_commandLine.IsValid) { s_commandLine.WriteUsage(); return; } // Get Shard Map Manager ShardMapManager smm = ShardMapManagerFactory.GetSqlShardMapManager( GetConnectionString(), ShardMapManagerLoadPolicy.Eager); Console.WriteLine("Connected to Shard Map Manager"); // Get Shard Map ShardMap map = smm.GetShardMap(s_commandLine.ShardMap); Console.WriteLine("Found {0} shards", map.GetShards().Count()); // Create connection string for MultiShardConnection string connectionString = GetCredentialsConnectionString(); // REPL Console.WriteLine(); while (true) { // Read command from console string commandText = GetCommand(); if (commandText == null) { // Exit requested break; } // Evaluate command string output; using (MultiShardConnection conn = new MultiShardConnection(map.GetShards(), connectionString)) { output = ExecuteCommand(conn, commandText); } // Print output Console.WriteLine(output); } } catch (Exception e) { // Print exception and exit Console.WriteLine(e); return; } }
public void commandLine_tryGetValue_using_valid_args_should_return_expected_value() { var expectedValue = 1000; var target = new CommandLine( new[] { "-d=1000" } ); Int32 value; Boolean actual = target.TryGetValue<Int32>( "d", out value ); actual.Should().Be.True(); value.Should().Be.EqualTo( expectedValue ); }
public static int Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledEx); CommandLine cmd = new CommandLine(args); if (cmd.Length < 2) { Console.WriteLine(""); Console.WriteLine("GamePower Compiler v1.0"); Console.WriteLine(""); Console.WriteLine("Usage: gpc.exe -i <input.prg> -o <output.js>"); Console.WriteLine(""); Console.WriteLine("Notes: If the -o argument is not passed, the output file will be created"); Console.WriteLine("in the caller folder with the .js extension."); return -1; } try { String filename = cmd["i"]; FileInfo fi = new FileInfo(filename); String inFile = filename; String outFile = cmd.ContainsArg("o") ? cmd["o"] : String.Empty; GPCompiler Compiler = new GPCompiler(); String[] lines; lines = File.ReadAllLines(filename, cmd.ContainsArg("msdos") ? Encoding.GetEncoding(437) : Encoding.Default); List<String> JSOutput = Compiler.Convert(lines.ToList()); List<String> PreOutput = new List<String>(); List<String> Output = new List<String>(); Output.AddRange(PreOutput); Output.Add(""); Output.AddRange(JSOutput); Output.Add(""); Output.Add(Compiler.GPEngineVarName + ".Init(" + Compiler.ProgramProcess + ");"); String Compiled = String.Join(Environment.NewLine, Output.ToArray()); String OutputFilename = cmd.ContainsArg("o") ? cmd["o"] : fi.Directory.FullName + fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length) + ".js"; using (StreamWriter sw = new StreamWriter(OutputFilename)) { sw.WriteLine(Compiled); } } catch (Exception e) { Console.Error.WriteLine(e.Message); Console.Error.WriteLine(e.StackTrace); return -1; } return 0; }
public void RunApplication(string[] args) { var cmdLine = new CommandLine(); cmdLine.Parse(args); string path = !String.IsNullOrEmpty(cmdLine.OutputDirectory) ? cmdLine.OutputDirectory : Path.Combine(Environment.CurrentDirectory, "OverlayTestImages"); var testImages = new GeneratedOverlayTestImages(path); foreach (var file in testImages.GetAll()) Console.WriteLine(file.Filename); }
static void Main(string[] args) { GameServer server = new GameServer(); CommandLine CmdLine = new CommandLine(); server.Init(); Thread CmdParser = new Thread(new ThreadStart(CmdLine.Run)); Thread Acceptor = new Thread(new ThreadStart(server.Acceptor)); Thread GameServer = new Thread(new ThreadStart(server.Run)); CmdParser.Start(); Acceptor.Start(); GameServer.Start(); }
public void RunApplication(string[] args) { var commandLine = new CommandLine(); try { commandLine.Parse(args); } catch (Exception e) { Platform.Log(LogLevel.Info, e); Console.WriteLine(e.Message); commandLine.PrintUsage(Console.Out); Environment.Exit(-1); } try { DicomServer.DicomServer.UpdateConfiguration(new DicomServerConfiguration { HostName = commandLine.HostName, AETitle = commandLine.AETitle, Port = commandLine.Port }); } catch (Exception e) { Console.WriteLine(e.Message); Platform.Log(LogLevel.Warn, e); Environment.Exit(-1); } try { if (!String.IsNullOrEmpty(commandLine.FileStoreDirectory)) StudyStore.UpdateConfiguration(new StorageConfiguration { FileStoreDirectory = commandLine.FileStoreDirectory, MinimumFreeSpacePercent = commandLine.MinimumFreeSpacePercent != null ? double.Parse(commandLine.MinimumFreeSpacePercent) : StorageConfiguration.AutoMinimumFreeSpace }); } catch (Exception e) { Console.WriteLine(e.Message); Platform.Log(LogLevel.Warn, e); Environment.Exit(-1); } }
public CdCommand CommandType(string script) { var commandLine = new CommandLine(script); var function = commandLine.Function; if (Regex.IsMatch(function, @"^[\w]:$")) { return CdCommand.Prompt; } if (Regex.IsMatch(function, @"^cd\\$")) { return CdCommand.Slash; } return Regex.IsMatch(function, @"^cd$") ? CdCommand.Regular : CdCommand.None; }