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.

How do I print the help screen?

See original GitHub issue

Issue by ptr727 Tuesday May 23, 2017 at 17:02 GMT _Originally opened as https://github.com/gsscoder/commandline/issues/445_


How do I print the help output I’ve evaluated the logical options and something is wrong?

            // Parse the commandline arguments
            // https://github.com/gsscoder/commandline
            Parser parser = new Parser(with =>
            {
                with.CaseSensitive = false;
                with.HelpWriter = Console.Error;
            });
            ParserResult<Options> result = parser.ParseArguments<Options>(args);
            if (result.Tag == ParserResultType.NotParsed)
            {
                return -1;
            }
            Options options = ((Parsed<Options>)result).Value;

            // Process or monitor must be specified
            if (options.ProcessFolders == false && options.MonitorFolders == false)
            {
                // TODO : Call help output directly
                return -1;
            }

Issue Analytics

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

github_iconTop GitHub Comments

7reactions
ericnewton76commented, Nov 4, 2017

Comment by veleek Tuesday Jul 25, 2017 at 23:23 GMT


I believe that this is definitely a bug in the code. If you use the overload of AutoBuild(...) that takes onError and onExample functions then it will write successfully.

It actually has an explicit block in the code which checks whether or not the ParserResult<T> being passed in is a NotParsed result in which case it gracefully attempts to write the error output.

if (onError != null && parserResult.Tag == ParserResultType.NotParsed)
{
    errors = ((NotParsed<T>)parserResult).Errors;

    if (errors.OnlyMeaningfulOnes().Any())
        auto = onError(auto);
}

So, as a workaround in the meantime you can just use

Console.WriteLine(HelpText.AutoBuild(result, null, null));
3reactions
Kittyfistocommented, Sep 4, 2019

The above workaround does not work for me (throws a NullReferenceException, using CommandLineParser 2.6.0), however only a simple change was needed to make it work:

Console.WriteLine(HelpText.AutoBuild(result, _ => _, _ => _));
Read more comments on GitHub >

github_iconTop Results From Across the Web

How Do I Print Screen On My PC | HP® Tech Takes
Press the main Win key and PrtSc at the same time. This will take a screenshot of the entire current screen. The screen...
Read more >
Copy the window or screen contents
Click the window that you want to copy. Press ALT+PRINT SCREEN. Paste (CTRL+V) the image into an Office program or other application.
Read more >
Print Anything You See on Your Screen – Video Tip
Open your favorite word processor (if you are using Word, sometimes it needs to be open before you hit the Print Screen button)....
Read more >
How to Print Your Screen in 3 Easy Steps
Open the “Pictures/Screenshots” folder in your user profile and double-click your screenshot. Press “File” and then “Print”.
Read more >
Printing HELP Screens
When you display HELP files, you can get a printed copy of the screen by pressing PA2 while the screen is displayed. To...
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