Giter Site home page Giter Site logo

Comments (10)

patriksvensson avatar patriksvensson commented on May 31, 2024 1

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.

patriksvensson avatar patriksvensson commented on May 31, 2024 1

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.

AraHaan avatar AraHaan commented on May 31, 2024

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.

patriksvensson avatar patriksvensson commented on May 31, 2024

@AraHaan You can set the default command by using CommandApp<T>.

var app = new CommandApp<MyDefaultCommand>();

from spectre.console.

AraHaan avatar AraHaan commented on May 31, 2024

@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.

patriksvensson avatar patriksvensson commented on May 31, 2024

@AraHaan I'm sorry, but I don't quite follow what you mean.

from spectre.console.

FrankRay78 avatar FrankRay78 commented on May 31, 2024

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.

AraHaan avatar AraHaan commented on May 31, 2024

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.

FrankRay78 avatar FrankRay78 commented on May 31, 2024

Hi @AraHaan, I'm just triaging the open CLI issues. Has Patrik's response fully addressed your ask?

from spectre.console.

FrankRay78 avatar FrankRay78 commented on May 31, 2024

Closing. Feel free to reopen if something remains outstanding.

from spectre.console.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.