Why does using --help do this?
See original GitHub issueOut of interest now when I use --help
I get the help listed twice:
C:\Program Files (x86)\Meeting Schedule Assistant\OutlookCalIFConsole>outlookcalifconsole --help
OutlookCalIFConsole 2018.4.4.1
Copyright c 2017 - 2018
-l, --list Builds a list of available calendars. Eg: -l ".\CalendarList.xml"
-m, --mode Type of events to add to the calendar. Modes: mwb. Eg: -m mwb
-p, --path Path to the events data file. Eg: -p ".\EventsToAdd.xml"
-t, --tokencache Required. The location of the token cache data file. Eg: -t "file.dat"
-e, --errorlog Required. The location for the error log. Eg: -e "<path to error folder>"
-s, --signout Sign out from Outlook calendar
--help Display this help screen.
--version Display version information.
OutlookCalIFConsole 2018.4.4.1
Copyright c 2017 - 2018
-l, --list Builds a list of available calendars. Eg: -l
".\CalendarList.xml"
-m, --mode Type of events to add to the calendar. Modes: mwb. Eg: -m
mwb
-p, --path Path to the events data file. Eg: -p ".\EventsToAdd.xml"
-t, --tokencache Required. The location of the token cache data file. Eg:
-t "file.dat"
-e, --errorlog Required. The location for the error log. Eg: -e "<path
to error folder>"
-s, --signout Sign out from Outlook calendar
--help Display this help screen.
--version Display version information.
Why might this be? If I use --version
it is not listed twice.
I am using standard code to build the help:
static int Main(string[] args)
{
var parserResult = CommandLine.Parser.Default.ParseArguments<Options>(args);
parserResult.WithParsed<Options>(options => OnSuccessfulParse(options));
parserResult.WithNotParsed<Options>(errs =>
{
var helpText = HelpText.AutoBuild(parserResult, h =>
{
return HelpText.DefaultParsingErrorsHandler(parserResult, h);
}, e =>
{
return e;
});
Console.WriteLine(helpText);
ReturnErrorCode = ErrorCode.CommandLineArguments;
});
return (int)ReturnErrorCode;
}
Also, why doesn’t the default help
keyword have a short version of h
?
Looking here:
/// <summary>
/// Creates a new instance of the <see cref="CommandLine.Text.HelpText"/> class,
/// automatically handling verbs or options scenario.
/// </summary>
/// <param name='parserResult'>The <see cref="CommandLine.ParserResult{T}"/> containing the instance that collected command line arguments parsed with <see cref="CommandLine.Parser"/> class.</param>
/// <param name="maxDisplayWidth">The maximum width of the display.</param>
/// <returns>
/// An instance of <see cref="CommandLine.Text.HelpText"/> class.
/// </returns>
/// <remarks>This feature is meant to be invoked automatically by the parser, setting the HelpWriter property
/// of <see cref="CommandLine.ParserSettings"/>.</remarks>
public static HelpText AutoBuild<T>(ParserResult<T> parserResult, int maxDisplayWidth = DefaultMaximumLength)
{
if (parserResult.Tag != ParserResultType.NotParsed)
throw new ArgumentException("Excepting NotParsed<T> type.", "parserResult");
var errors = ((NotParsed<T>)parserResult).Errors;
if (errors.Any(e => e.Tag == ErrorType.VersionRequestedError))
return new HelpText(HeadingInfo.Default){MaximumDisplayWidth = maxDisplayWidth }.AddPreOptionsLine(Environment.NewLine);
if (!errors.Any(e => e.Tag == ErrorType.HelpVerbRequestedError))
return AutoBuild(parserResult, current => DefaultParsingErrorsHandler(parserResult, current), e => e, maxDisplayWidth: maxDisplayWidth);
var err = errors.OfType<HelpVerbRequestedError>().Single();
var pr = new NotParsed<object>(TypeInfo.Create(err.Type), Enumerable.Empty<Error>());
return err.Matched
? AutoBuild(pr, current => DefaultParsingErrorsHandler(pr, current), e => e, maxDisplayWidth: maxDisplayWidth)
: AutoBuild(parserResult, current => DefaultParsingErrorsHandler(parserResult, current), e => e, true, maxDisplayWidth);
}
It seems to me that it itself calls DefaultParsingErrorsHandler
. Yet in my code it looks like we do it again. Is this a mistake in my code or something?
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
'Help do' vs. 'help to do' vs. 'help doing' in English
Both "help someone do something" and "help someone to do something" are acceptable. The form without "to" seems to be more common in...
Read more >Help to do something or help do something?
It can be used as a full verb and as a modal verb. Today it is almost normal to use "to help" with...
Read more >'it does help' why do you use 'do' in this sentence? Is it the ...
"it helps" is just stating the fact while "it does help" is emphasizing that it indeed helps. the emphasis might be in response...
Read more >Help somebody (to) do - Grammar - Cambridge Dictionary
Help somebody (to) do ... We use help with or without an object: Let me help you. Can I help? We also use...
Read more >What is the difference between “help do something” and “ ...
First phrase means to actually engage in the work to get something done: 'I helped her do the dishes.' Second phrase is to...
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 Free
Top 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
Nulling the HelpWriter works:
var parserResult = new Parser(with => with.HelpWriter = null).ParseArguments<Options>(args);
Instead of:var parserResult = CommandLine.Parser.Default.ParseArguments<Options>(args);
Nulling the HelpWriter still shows a default help in my case :
Calling
myProgram.exe --help
in a CLI returns :While my understanding is that it should print nothing. Tested on 2.8.0