Skip to content

Use case of starfruit and generic host #915

Open
@NikiforovAll

Description

@NikiforovAll

Moved from KathleenDollard/command-line-api-starfruit#49

Question: How can we use Generic Host alongside with the Starfruit?

Context: A lot of open-source projects incorporate Attribute-first approach. But it looks like not so many projects could be used together with Generic Host that easily. AFAIK, Starfruit app model is designed with the idea to hide the complexity and get rid of the dependency on System.CommandLine. Currently, it is only possible to wire up Generic Host via CommandLineBuilder.UseHost method

Activity

KathleenDollard

KathleenDollard commented on Jun 9, 2020

@KathleenDollard
Contributor

Thanks for moving this. I definitely want to tie these together.

One key point about StarFruit is that it doesn't have to be attribute (and isn't initially entirely). There's a standard set of rules that use a lot of attributes, but the standard set of rules might evolve.

Yes, the key point of StarFruit is to avoid seeing any, or almost any, System.CommandLine complexity, unless you're doing something super special.

To be honest, I'm just starting to look at this, so what do you think the perfect Main would look like for a non-trivial CLI?

KathleenDollard

KathleenDollard commented on Jun 9, 2020

@KathleenDollard
Contributor

Sorry, nm. I am looking at your PR and will comment afterwards

NikiforovAll

NikiforovAll commented on Jun 9, 2020

@NikiforovAll
ContributorAuthor

OK, great. 🙆‍♂️
I think the DI scenario could be supported by adding a separate package with extension method(s) to configure CommandLineBuilder.
For example:
System.CommandLine.ReflectionAppModel.DependencyInjection

CommandLineHost.CreateDefaultBuilder()
    .ConfigureCommandLineDefaults((CommandLineBuilder builder) =>
    {
        builder.UseReflectionAppModel(config => {/* ... */};
    })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jonsequitur@KathleenDollard@NikiforovAll

        Issue actions

          Use case of starfruit and generic host · Issue #915 · dotnet/command-line-api