-
-
Notifications
You must be signed in to change notification settings - Fork 513
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
Add overload to allow one to set default command within the configuration delegate. #1469
Comments
I guess another alternative would be adding a way to have |
@AraHaan You can set the default command by using var app = new CommandApp<MyDefaultCommand>(); |
Could, but that does not allow one to specify a specific name for the default command either. So I am thinking of ways around that as well. |
@AraHaan I'm sorry, but I don't quite follow what you mean. |
This is how Spectre.Console default commands are designed to work. If you want to add a named command as well, you do it in the configure phase. var app = new CommandApp<InstallCommand>(); // Default command
app.Configure(config =>
{
_ = config.AddCommand<InstallCommand>("install").WithDescription("Installs the Workload.");
_ = config.AddCommand<UninstallCommand>("uninstall").WithDescription("Uninstalls the Workload.");
_ = config.AddCommand<UpdateCommand>("update").WithDescription("Updates the Workload.");
}); |
Has this now cleared up your issue @AraHaan? |
Yes, but I would like a way to do it with and without the generic version of public class CommandApp<T> : CommandApp
{
// ctor that bootstraps setting the passed in T as the default command.
} |
You can do that now as well: var app = new CommandApp();
app.SetDefaultCommand<InstallCommand>();
app.Configure(config =>
{
_ = config.AddCommand<InstallCommand>("install").WithDescription("Installs the Workload.");
_ = config.AddCommand<UninstallCommand>("uninstall").WithDescription("Uninstalls the Workload.");
_ = config.AddCommand<UpdateCommand>("update").WithDescription("Updates the Workload.");
}); |
Hi @AraHaan, I'm just triaging the open CLI issues. Has Patrik's response fully addressed your ask? |
Closing. Feel free to reopen if something remains outstanding. |
Is your feature request related to a problem? Please describe.
For basic apps one can set the default command outside of the .Configure function.
That is alright until you want for:
Action<IConfiguator<TSettings>
to make use of the generic version of that interface, which can be used to configure additional things that is normally not possible without the generic version.Describe the solution you'd like
For a change like this to be accepted, AraHaan@636ddb5
Describe alternatives you've considered
Perhaps having it as an extension method that extends
CommandApp
?Additional context
This code above could be greatly simplified if I could configure using the overload version proposed here to set the default command instead of making a dummy list and possibly having bugs in my code, I then could also directly pass in
args
toapp.RunAsync
which will also improve performance of my application for free as well.The text was updated successfully, but these errors were encountered: