public class ApiContext : SharedContext
{
[OptionDescriptor("P1",
required:false, defaultValue :"my default",
helpText:"Specify something.")]
public string P1 { get; set; }
[OptionSet]
public ConnectionParameters ConnectionParameters{ get; set; }
}
// This information is used by many other Commands, too.
public class ConnectionParameters
{
[OptionDescriptor("Username", required:true)]
public string Username { get; set; }
[OptionDescriptor("Password", required:true)]
public string Password { get; set; }
}
public class ApiCommand : CommandBase2<ApiContext>
{
//..
protected override void Execute()
{
Print.Info($"P1 = {this.Context.P1}");
Print.Info($"Url = {this.Context.Url}");
Print.Info($"Username= {this.Context.ConnectionParameters.Username}");
Print.Info($"Password= {this.Context.ConnectionParameters.Password}");
}
//...