Skip to content

Instantly share code, notes, and snippets.

@agc93
Created October 10, 2017 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agc93/a84c9daff32a50c01f135816d48141d7 to your computer and use it in GitHub Desktop.
Save agc93/a84c9daff32a50c01f135816d48141d7 to your computer and use it in GitHub Desktop.
Sample of Spectre desired behaviour
public class MyCommand : Command<MyCommandSettings> { /* TRIMMED */ }
public class MyOtherCommand : Command<MyOtherCommandSettings> { /* TRIMMED */ }
// EXTRACT ONLY
var app = new CommandApp();
app.Configure(config =>
{
/*// Register commands. */
config.AddProxy<ProxySettings>("proxy", profile =>
{
profile.AddCommand<MyCommand>("child");
profile.AddCommand<MyOtherCommand>("other");
});
// Run the application.
});
return app.Run(args);
public class ProxySettings {}
public abstract class SharedCommandSettings : ProxySettings
{
[Argument(0, argumentName: "[Name]")]
[Description("Name")]
public virtual string Name {get;set;}
}
public sealed class MyCommandSettings : SharedCommandSettings
{
[Option("--from <SOURCE>")]
public string Source {get;set;}
}
public sealed class MyOtherCommandSettings : SharedCommandSettings
{
[Option("--verbose")]
public bool Verbose {get;set;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment