-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sub-commands? #23
Comments
You can use arguments to effect sub commands. Your Oakton command can vary on what it actually does by just doing a switch in the Execute on the argument. Oakton was originally built in the FubuCore days -- for better or worse -- as a way to build tools like the git cli |
Do you mean using something like this: [Description("Work with volumes", Name = "volume")]
public class VolumeCommand : OaktonAsyncCommand<VolumeInput>
{
private readonly AppConfig appConfig;
public VolumeCommand(AppConfig appConfig)
{
this.appConfig = appConfig;
Usage("Work with a volume").Arguments(x => x.Action, x => x.Name);
}
public override async Task<bool> Execute(VolumeInput input)
{
// Switch on input.Action here
}
}
public class VolumeInput
{
public CommandAction Action { get; set; } = VolumeAction.ls;
public string Name { get; set; };
public enum CommandAction
{
create,
ls,
inspect,
rm,
}
} Let's say I also wanted a command |
For reference, I worked around this by handling the top level commands myself, then building a @jeremydmiller BTW, I really like how simple yet well-featured this library is compared to the bigger ones! |
I'm wondering if there is currently any supported way to use sub-commands?
I'm thinking of the way the Docker CLI works, for example:
We can break down the first example like:
I thought perhaps command aliases could have a space in them, which could make this work:
Unfortunately this doesn't work, and I guess it would break handling of enumerable arguments.
The text was updated successfully, but these errors were encountered: