Skip to content
gsscoder edited this page Jan 17, 2013 · 28 revisions

From Version 1.9.4.91 you get the opportunity to define a syntax similar to git or other popular command line tools.

$ git commit -a
$ git push -u origin commit
$ git tag -a tagname -m 'Tag Description'

commit, push, and _tag are all verb commands. The options that follows are options ordinary, defined as specified in Mapping Properties To Options.

To begin we will define three ordinary options class:

class CommitSubOptions
{
  [Option('a', "all", HelpText="Tell the command to automatically stage files.")]
  public bool All { get; set; }
  // Remainder omitted
}

class PushSubOptions
{
  // Remainder omitted
}

class TagSubOptions
{
  // Remainder omitted 
}

If the remainder were not omitted, XXXSubOptions::GetUsage() would not have been defined. Now we can define the master options class that will host all these sub options.

class Options
{
  public OptionsWithVerbsHelp()
  {
    CommitVerb = new CommitSubOptions {Patch = true};
  }
 
  [VerbOption("commit", HelpText = "Record changes to the repository.")]
  public CommitSubOptions CommitVerb { get; set; }

  [VerbOption("push", HelpText = "Update remote refs along with associated objects.")]
  public PushOptions AddVerb { get; set; }
 
  [VerbOption("tag", HelpText = "Update remote refs along with associated objects.")]
  public TagSubOptions CloneVerb { get; set; }
}