Display help when no option is specified
See original GitHub issueIssue 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:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wiki with lot of examples
Closed for age.