public static void SetupCommand(ParserSetup parserSetup) { var command = parserSetup .Command <DateCommandOptions>() .Name("date") .Help("Displays a date and time and optionally calculates the difference to another date and time.") .ExampleUsage("Toolbox date --utc"); command .Option(a => a.Date) .Name("date") .DefaultValue(DateTime.Now) .Help("The date and time to display. If not specified the current system date and time are used."); command .Option(a => a.Offset) .Name("offset") .DefaultValue(TimeSpan.Zero) .Help("Offsets the date and time by the specified duration before displaying it. Format is HH:MM:SS."); command .Option(a => a.DisplayInUtc) .Name("utc") .Help("Converts the date and time to UTC before displaying it."); command .Option(a => a.DifferenceToDate) .Name("differenceTo") .Help("If specified the difference between the first date (option --date) and this date is displayed."); command.Validate(Validate); }
public static void SetupCommand(ParserSetup parserSetup) { var command = parserSetup .Command <FileReplaceCommandOptions>() .Name("fileReplace") .Help("Reads text from a file, replaces a text with another text and saves the result to a new file.") .ExampleUsage("Toolbox fileReplace --in In.txt --out Out.txt --pattern cat --replaceWith dog"); command .Option(a => a.InFile) .Name("in") .Help("The file to read the text from.") .IsRequired(); command .Option(a => a.OutFile) .Name("out") .Help("The file to write the result to.") .IsRequired(); command .Option(a => a.Pattern) .Name("pattern") .Help("The text to replace.") .IsRequired(); command .Option(a => a.Replacement) .Name("replaceWith") .Help("The replacement text.") .IsRequired(); command .Option(a => a.IgnoreCase) .Name("ignoreCase") .Help("Ignores casing when searching for the specified text (--pattern)."); command .Option(a => a.OverrideOutFile) .Name("override") .Help("Overrides the output file if it already exists. If this option is not enabled and the output file already exists an error will be shown."); command .Option(a => a.UseRegularExpressions) .Name("regex") .Help("Treats the given pattern (--pattern) as a regular expression."); command .Option(a => a.DisplayResult) .Name("display") .Help("Displays the result on the console."); command.Validate(Validate); }
public void Command_ShouldReturnNewNamedCommandSetup() { var parser = A.Fake <Parser>(); var commandParser = A.Fake <CommandParser <Command1Options> >(); var commandSetup = A.Fake <NamedCommandSetup <Command1Options> >(); var setup = new ParserSetup(parser); A.CallTo(() => parser.GetOrCreateCommandParser <Command1Options>("command1")).Returns(commandParser); A.CallTo(() => this.DependencyResolver.Resolve <NamedCommandSetup <Command1Options> >(parser, commandParser)).Returns(commandSetup); setup.Command <Command1Options>().Should().Be(commandSetup); }
public static void SetupCommand(ParserSetup parserSetup) { var command = parserSetup .Command <LongestWordCommandOptions>() .Name("longestWord") .Help("Gets the longest word of a list of words.") .ExampleUsage("Tool longestWord --words cat dog fish crocodile"); command .Option(a => a.Words) .Name("words") .Help("The list of words.") .IsRequired(); }
public static void SetupCommand(ParserSetup parserSetup) { var command = parserSetup .Command <ConvertGuidCommandOptions>() .Name("convertGuid") .Help("Converts a guid.") .ExampleUsage("Toolbox convertGuid --guid ac23ddb2-6e34-46a9-80f4-9d6fe6f87558 --to Bytes"); command .Option(a => a.Guid) .Name("guid") .Help("The Guid to be converted.") .IsRequired(); command .Option(a => a.Mode) .Name("to") .Help("Defines to which the Guid should converted.") .EnumValueHelp(ConvertGuidMode.Bytes, "Converts the Guid to a sequence of bytes.") .EnumValueHelp(ConvertGuidMode.BigInteger, "Converts the Guid to a big integer."); }