Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when turning off AutoHelp or AutoVersion #821

Open
carstencodes opened this issue May 23, 2022 · 0 comments
Open

Issue when turning off AutoHelp or AutoVersion #821

carstencodes opened this issue May 23, 2022 · 0 comments

Comments

@carstencodes
Copy link

Symptom

When turning off AutoVersion (or AutoHelp) in the ParserSettings, the HelpText still announces these commands as being available.

Root cause

In the Parser Class, the method MakeParserResult is called, which may call DisplayHelp.

DisplayHelp calls HelpText.AutoBuild, which creates a HelpText instance with AutoVersion and AutoHelp always set to true no matter which value has been set in the ParserSettings instance.

How to reproduce

public static class Program {

[Verb("do")]
public class Options {
    [Option("what")]
    public string What { get; set; }
}

static void Main(string args[]){
Parser p = new Parser(s => { s.AutoVersion = false });
ParserResult<object> r = p.Parse<object>(args, typeof(Options));

}
}

Calling the project without any options results in a helptext that includes the 'version' command, which is officially turned of.

If the user then calls the application with the version verb, an error is produced, since the version verb is not known.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant