Comments (10)
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.");
});
from spectre.console.
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.");
});
from spectre.console.
I guess another alternative would be adding a way to have AddCommand
where one can specify it to be a default command (bool value with default of it being false) as well, with a name different from the default name for said default command. 😄
from spectre.console.
@AraHaan You can set the default command by using CommandApp<T>
.
var app = new CommandApp<MyDefaultCommand>();
from spectre.console.
@AraHaan You can set the default command by using
CommandApp<T>
.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.
from spectre.console.
@AraHaan I'm sorry, but I don't quite follow what you mean.
from spectre.console.
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.
Has this now cleared up your issue @AraHaan?
from spectre.console.
Yes, but I would like a way to do it with and without the generic version of CommandApp
which would be great (not to mention help unify both versions similarly which would help make it more maintainable as then the generic version could be defined as this exactly:
public class CommandApp<T> : CommandApp
{
// ctor that bootstraps setting the passed in T as the default command.
}
from spectre.console.
Hi @AraHaan, I'm just triaging the open CLI issues. Has Patrik's response fully addressed your ask?
from spectre.console.
Closing. Feel free to reopen if something remains outstanding.
from spectre.console.
Related Issues (20)
- Progress update causes heavy flickering (regression from 0.47.0 to 0.48.0) HOT 2
- Release a new version with support for InterceptResult as described in documentation HOT 1
- Sixlabors ImageSharp 3.X?
- Add interactive input fields HOT 1
- Built-in parameter `--version` conflicts with existing one HOT 9
- `ExplainCommand+Settings` ctor fails `ServiceProvider.ValidateService` HOT 1
- Bad rendering for table live display / hidden table headers / no border and forced refresh
- Search doesn't work properly in selection prompts HOT 1
- Add paging function to selection prompt
- Fill entire background with custom color
- Unable to redirect output to file HOT 1
- More control over output - padding HOT 2
- Allow for a custom search filtering function for the SelectionPrompt
- Allow for multiple matching search result items with the SelectionPrompt
- Add '-?' as an additional alias for '-h' and '--help', just like 'dotnet -?' HOT 4
- Detecting and handling unicode support HOT 1
- Add public API to display help manually by user code HOT 1
- ValidationResult.Error should accept/support markup string when returing from CommandSettings.Validate method. HOT 1
- Can't find how to render panel to whole screen HOT 2
- Request: ability to display part of table rows
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spectre.console.