public void ResultHelpTextContainsNecessaryInfo() { var help = new HelpGenerator(); var text = help.Generate(typeof(TestOptions)); Assert.IsTrue(text.Contains(VerbName)); Assert.IsTrue(text.Contains(VerbHelpText)); Assert.IsTrue(text.Contains(ShortOptionName.ToString())); Assert.IsTrue(text.Contains(LongOptionName)); Assert.IsTrue(text.Contains(OptionHelpText)); }
public void Help(object _) { var switches = HelpGenerator.Generate <DyaOptions>("-").TrimEnd('\r', '\n'); var commands = HelpGenerator.Generate(typeof(CommandDispatcher), Prefix).TrimEnd('\r', '\n'); Printer.LineFeed(); Printer.Output("Command line switches:"); Printer.Output(switches); Printer.LineFeed(); Printer.Output("Commands:"); Printer.Output(commands); }
public void WriteEmpty() { // Arrange var application = new KingpinApplication(console); // Act var subject = new HelpGenerator(application, console); var appText = subject.ReadResourceInExecutingAssembly("KingpinNet.Help.ApplicationHelp.liquid"); subject.Generate(writer, appText); // Assert var result = writer.ToString(); output.WriteLine(result); Assert.Contains("usage:", result); }
public void WriteGlobalFlagWithShortName() { // Arrange var application = new KingpinApplication(console); application.Flag("flag", "flag help").Short('f'); // Act var subject = new HelpGenerator(application, console); var appText = subject.ReadResourceInExecutingAssembly("KingpinNet.Help.ApplicationHelp.liquid"); subject.Generate(writer, appText); // Assert var result = writer.ToString(); output.WriteLine(result); Assert.Contains($"Flags:", result); Assert.Contains($" -f, --flag=<value> flag help", result); }
public void WriteGlobalArgument() { // Arrange var application = new KingpinApplication(console); application.Argument("arg", "arg help"); // Act var subject = new HelpGenerator(application, console); var appText = subject.ReadResourceInExecutingAssembly("KingpinNet.Help.ApplicationHelp.liquid"); subject.Generate(writer, appText); // Assert var result = writer.ToString(); output.WriteLine(result); Assert.Contains($"usage: [<arg>]", result); Assert.Contains($"Args:", result); Assert.Contains($" [<arg>] arg help", result); }
public void WriteGlobalCommandWithFlagAndDefaultValue() { // Arrange var application = new KingpinApplication(console); var command = application.Command("cmd", "command help"); command.Flag("flag", "flag help").Default("1234.5678"); // Act var subject = new HelpGenerator(application, console); var appText = subject.ReadResourceInExecutingAssembly("KingpinNet.Help.ApplicationHelp.liquid"); subject.Generate(writer, appText); // Assert var result = writer.ToString(); output.WriteLine(result); Assert.Contains($"usage: <command>", result); Assert.Contains($"Commands:", result); Assert.Contains($" cmd --flag=<1234.5678> flag help command help", result); }
public void WriteGlobalCommand() { // Arrange var application = new KingpinApplication(console); application.Command("cmd", "command help"); // Act var subject = new HelpGenerator(application, console); var appText = subject.ReadResourceInExecutingAssembly("KingpinNet.Help.ApplicationHelp.liquid"); subject.Generate(writer, appText); // Assert var result = writer.ToString(); output.WriteLine(result); Assert.Contains($"usage: <command>", result); Assert.Contains($"Commands:", result); Assert.Contains($" cmd", result); Assert.Contains($" command help", result); }
public void WriteGlobalCommandWithFlagAndExamples() { // Arrange var application = new KingpinApplication(console); var command = application.Command("cmd", "command help"); command.Flag("flag", "flag help").SetExamples("1", "2"); // Act var subject = new HelpGenerator(application, console); var appText = subject.ReadResourceInExecutingAssembly("KingpinNet.Help.CommandHelp.liquid"); subject.Generate(command, writer, appText); // Assert var result = writer.ToString(); output.WriteLine(result); Assert.Contains($"usage: cmd [<flags>]", result); Assert.Contains($" command help", result); Assert.Contains($"Flags:", result); Assert.Contains($" --flag=<value> flag help (e.g. 1, 2)", result); }
public void WriteHelpForNestedCommand() { // Arrange var application = new KingpinApplication(console); var command = application.Command("cmd1", "command1 help"); command.Command("cmd2", "command2 help"); // Act var subject = new HelpGenerator(application, console); var appText = subject.ReadResourceInExecutingAssembly("KingpinNet.Help.CommandHelp.liquid"); subject.Generate(command, writer, appText); // Assert var result = writer.ToString(); output.WriteLine(result); Assert.Contains($"usage: cmd1 <command>", result); Assert.Contains($"command1 help", result); Assert.Contains($"Commands:", result); Assert.Contains($" cmd2 command2 help", result); }
public void WriteNestedCommandWithGlobalCommandWithAFlag() { // Arrange var application = new KingpinApplication(console); var command = application.Command("cmd1", "command1 help"); command.Flag("flag", "flag help"); command.Command("cmd2", "command2 help"); // Act var subject = new HelpGenerator(application, console); var appText = subject.ReadResourceInExecutingAssembly("KingpinNet.Help.ApplicationHelp.liquid"); subject.Generate(writer, appText); // Assert var result = writer.ToString(); output.WriteLine(result); Assert.Contains($"usage: <command>", result); Assert.Contains($"Commands:", result); Assert.Contains($" cmd1 --flag=<value> flag help command1 help", result); Assert.Contains($" cmd1 cmd2 command2 help", result); }
public void WriteFlagWithValueName() { // Arrange var application = new KingpinApplication(console); application.ApplicationName("x"); var command = application.Command("cmd", "command help"); command.Flag("flag", "flag help").ValueName("!name!"); // Act var subject = new HelpGenerator(application, console); var appText = subject.ReadResourceInExecutingAssembly("KingpinNet.Help.ApplicationHelp.liquid"); subject.Generate(writer, appText); // Assert var result = writer.ToString(); output.WriteLine(result); Assert.Contains($"usage: x <command>", result); Assert.Contains($"Commands:", result); Assert.Contains($" cmd --flag=!name!", result); Assert.Contains($" command help", result); }