public void PrintHelp_should_show_menu_for_one_command() { // Arrange var command = new CommandInfo("commit"); command.WithParameter <string>("Author") .SetDescription("This is the author name.") .SetDefault("john"); command.WithParameter <string>("Message") .SetAlias("m", "message", "msg") .SetDescription("This is a message.") .Required(); command.WithParameter <bool>("Append") .SetAlias("a", "append") .SetDescription("This is a boolean."); command.WithParameter <Sex>("Date") .SetAlias("d") .SetDescription("The commit date"); command.AddExample("commit -m foobar", "This is an example."); command.AddExample("commit -a", "This is another example."); command.AddLinks("http://github.com/Ackara"); command.AddLinks("http://codeplex.com/Ackara"); var sut = new EditableHelpBuilder(true); EditableHelpBuilder.HeaderFormatString = "{2}"; // Act sut.PrintHelp(command); // Assert Approvals.Verify(sut.Debug); }
private static IEnumerable <CommandInfo> GetCommandList() { var one = new CommandInfo <NonDecoratedCommand>("one") { Cmdlet = "Write-Foo" }; one.SetDescription("This is a good command.") .WithParameter(x => x.NumericValue) .SetDescription("An id value.") .Required() .WithParameter(x => x.PrecisionValue, "coordinate") .SetDescription("An number value.") .SetAlias("point") .SetDefault(0) .WithParameter(x => x.CharValue) .SetDescription("A char value.") .SetAlias("c") .SetDefault('c') .WithParameter(x => x.Collection) .SetDescription("An array") .SetAlias("l", "list") .SetDefault(new string[] { "a", "b", "c" }) .WithParameter(x => x.DateValue) .SetDescription("A date value.") .SetAlias("d", "date") .SetDefault(DateTime.Now) .WithParameter(x => x.EnumValue) .SetDescription("A fake value.") .SetAlias("e") .SetDefault(FakeEnum.North); one.AddLinks("Write-Host"); one.AddExample("Write-Foo", "This does something."); one.AddExample("Write-Foo", "This does something.", true); var two = new CommandInfo("two"); two.SetDescription("This is a synopsis.") .WithParameter <string>("Id") .SetDescription("An id value.") .Required() .WithParameter("Contact", typeof(string), "phone") .SetDescription("A phone number") .SetAlias("tel"); return(new CommandInfo[] { one, two }); }