/// <summary> /// Prints a user friendly usage string describing the command line argument syntax. /// </summary> /// <param name="output">The command line output.</param> public void ShowUsage(CommandLineOutput output) { if (output == null) { throw new ArgumentNullException(@"output"); } foreach (Argument arg in arguments) { output.PrintArgumentHelp(@"/", arg.LongName, arg.ShortName, arg.Description, arg.ValueLabel, arg.ValueType); output.NewLine(); } if (SupportsResponseFiles) { output.PrintArgumentHelp(@"@", null, null, Resources.CommandLineArgumentParser_ResponseFileDescription, Resources.CommandLineArgumentParser_ResponseFileValueLabel, typeof(string)); output.NewLine(); } if (defaultArgument != null) { output.PrintArgumentHelp(null, null, null, defaultArgument.Description, defaultArgument.ValueLabel, defaultArgument.ValueType); output.NewLine(); } }
/// <summary> /// Runs the program. /// </summary> /// <param name="console">The console.</param> /// <param name="args">The command-line arguments.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="console"/> /// or <paramref name="args"/> is null.</exception> /// <exception cref="InvalidOperationException">Thrown if the program has already started running.</exception> public int Run(IRichConsole console, string[] args) { if (console == null) { throw new ArgumentNullException("console"); } if (args == null) { throw new ArgumentNullException("args"); } if (this.console != null) { throw new InvalidOperationException("The program has already started running."); } this.console = console; commandLineOutput = new CommandLineOutput(console); try { if (!console.IsRedirected) { console.Title = ApplicationTitle; } return(RunImpl(args)); } catch (Exception ex) { return(HandleFatalException(ex)); } finally { console.ResetColor(); } }
/// <summary> /// Prints a user friendly usage string describing the command line argument syntax. /// </summary> /// <param name="output">The command line output.</param> public void ShowUsage(CommandLineOutput output) { if (output == null) throw new ArgumentNullException(@"output"); foreach (Argument arg in arguments) { output.PrintArgumentHelp(@"/", arg.LongName, arg.ShortName, arg.Description, arg.ValueLabel, arg.ValueType); output.NewLine(); } if (SupportsResponseFiles) { output.PrintArgumentHelp(@"@", null, null, Resources.CommandLineArgumentParser_ResponseFileDescription, Resources.CommandLineArgumentParser_ResponseFileValueLabel, typeof (string)); output.NewLine(); } if (defaultArgument != null) { output.PrintArgumentHelp(null, null, null, defaultArgument.Description, defaultArgument.ValueLabel, defaultArgument.ValueType); output.NewLine(); } }
public void ConstructorWithTextWriterParameter() { CommandLineOutput output = new CommandLineOutput(_writer); Console.WriteLine(output.Output.GetType()); Assert.AreEqual(typeof(StringWriter), output.Output.GetType()); }
public void ConstructorWithConsoleTest() { CommandLineOutput output = new CommandLineOutput(NativeConsole.Instance); Assert.AreEqual(NativeConsole.Instance.Out.GetType(), output.Output.GetType()); }
public void TestStart() { _sbOutput = new StringBuilder(); _writer = new StringWriter(_sbOutput); _output = new CommandLineOutput(_writer, 80); }