Skip to content

Fluent interface for System.CommandLine #540

Open
@EifelMono

Description

@EifelMono

Hello everybody,

I have written a fluent interface for the System.CommandLine

Below is the sample from your wiki in fluent form.

static Task<int> Main(string[] args)
    => args.ArgsCommandBuilder("My sample app")
        .Option<int>("--int-option", 42, "An option whose argument is parsed as an int")
        .Option<bool>("--bool-option", default, "An option whose argument is parsed as a bool")
        .Option<FileInfo>("--file-option", default, "An option whose argument is parsed as a FileInfo")
        .OnRootCommand((intOption, boolOption, fileOption) =>
        {
            Console.WriteLine($"The value for --int-option is: {intOption}");
            Console.WriteLine($"The value for --bool-option is: {boolOption}");
            Console.WriteLine($"The value for --file-option is: {fileOption?.FullName ?? "null"}");
        })
        .RunAsync();

More doc, code, tests and samples can be found on my github side

I would like to bring this in these project if you think it is useful for others and fits in this project

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions