question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Display help when no option is specified

See original GitHub issue

Issue by nicolasr75 Friday Feb 05, 2016 at 14:55 GMT _Originally opened as https://github.com/gsscoder/commandline/issues/286_


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?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
moh-hassancommented, Jun 26, 2020

Wiki with lot of examples

0reactions
moh-hassancommented, Jun 26, 2020

Closed for age.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bash - Having getopts to show help if no options provided
What I want is getopts to spit out the help_message function when no option is triggered, say the script is launched just ./scriptname.sh ......
Read more >
Execute default option when no options are specified in ...
Adding a default option to the case statement won't help because it won't be executed if getopts doesn't have options to parse.
Read more >
How to execute default in getopts when no option is given
Getopts option -please help​​ Hello, I am using below code in AIX env to interpret -n option given in argument while executing the...
Read more >
R: Options Settings
This facilitates retrieving an option and checking whether it is set and setting it separately if not.
Read more >
argparse — Parser for command-line options, arguments ...
Specify the attribute name used in the result namespace. help ... description - Text to display before the argument help (by default, no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found