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.

After customizing help generation, hep VERB does not work

See original GitHub issue

Did this

static async Task Main( string[] args )
{
    _logger.Info(CommandLine.Text.HeadingInfo.Default);

    var parser = new Parser(p => { p.AutoVersion = false; p.CaseInsensitiveEnumValues = true;  });
    var parserResult = parser.ParseArguments<SyncOptions, QueryOptions, TokenOptions>(args);
    await parserResult.MapResult(
            (SyncOptions opts) => SyncAsync(opts),
            (QueryOptions opts) => QueryAsync(opts),
            (TokenOptions opts) => ShowTokenAsync(opts),
            errors => Task.FromResult(DisplayHelp(parserResult, errors))
        )
        .ContinueWith(t => {
            if ( System.Diagnostics.Debugger.IsAttached )
            {
                Console.WriteLine("Press enter...");
                Console.ReadLine();
            }
        });
}

private static int DisplayHelp<T>( ParserResult<T> result, IEnumerable<Error> errs )
{
    var helpText = CommandLine.Text.HelpText.AutoBuild(result, h =>
    {
        h.AdditionalNewLineAfterOption = false;
        h.AddNewLineBetweenHelpSections = true;
        h.AddEnumValuesToHelpText = true;
        h.AutoVersion = false;
        h.Heading = CommandLine.Text.HeadingInfo.Empty;
        h.MaximumDisplayWidth = 110;
        h.AddVerbs(typeof(SyncOptions), typeof(QueryOptions), typeof(TokenOptions));
        return CommandLine.Text.HelpText.DefaultParsingErrorsHandler(result, h);
    }, e => e,
    true);
    Console.WriteLine(helpText);
    return 1;
}

Before this I could type MyProgram help VERB and it would tell me the same as MyProgram VERB minus errors section. Now this gives me only verb list, like if help lost its first argument. This does not work either: MyProgram VERB help but this does: MyProgram VERB --help.

Am I doing something wrong here?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:16

github_iconTop GitHub Comments

2reactions
DkAngelitocommented, Jun 13, 2020

Upgrade your example to the latest version (2.8+) and change your helptext class for the following and it should work

var helpText = HelpText.AutoBuild(result, h =>
{
	h.AdditionalNewLineAfterOption = false; //remove the extra newline between options
	h.Heading = "Myapp 2.0.0-beta"; //change header
	h.Copyright = "Copyright (c) 2019 Global.com"; //change copyrigt text
	return HelpText.DefaultParsingErrorsHandler(result, h);
}
//		, e => e); Remove this line 
); // add this one
1reaction
sflankercommented, Nov 1, 2020

@DkAngelito Thank You!

// , e => e); Remove this line

This one line was what was throwing me off and I was banging my head on my keyboard. The overload with this should be marked obsolete and/or killed with fire. What a headache!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Agile Integration Software Essentials
Older one-to-one transformation engines do not satisfy the needs; XSLT transformation engines also do not meet the two criteria, because all data must...
Read more >
Ask the Editor Frequently Asked Style Questions
Q: If you have a hyphen in a headline, is the word after the hyphen capitalized? A: In AP headline style, only the...
Read more >
CA ARCserve® Backup for Windows
CA ARCserve® Backup Agent for Novell Open Enterprise Server for Linux ... The CLI does not support backup of some special files or...
Read more >
What is another word for custom?
What is another word for custom? ; procedure · proclivity ; ritual · wont ; bent · disposition ; mode · policy ;...
Read more >
Apple iPad sales disappoint, Street eyes holiday quarter
Apple Inc delivered another quarter of lacklustre results and iPad sales fell well short of Wall Street targets, pushing its stock down more ......
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