Skip to content

Display help when no option is specified #286

Open
@nicolasr75

Description

@nicolasr75

Using version 2.0:
When the user does not specify any option, I would like to display the same help screen that is automatically shown when the user specifies --help.
I have a very simple program and would like to use as much default behavior as possible. I am using only a few options and this is the code I am using for parsing:

var parserResult = Parser.Default.ParseArguments<CommandlineOptions>(args)

if (parserResult.Tag == ParserResultType.Parsed)
{
    CommandlineOptions options = ((Parsed<CommandlineOptions>)parserResult).Value;

    if(options....)
    {

    }
    ...
    else  //no options specified
    {
        Console.WriteLine(CommandLine.Text.HelpText.AutoBuild(parserResult)); //***
    }       
}

However, the line marked with *** does not work because it expects a NotParsed instance. How could I generate the help output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions