commandlineparser / commandlineparser/commandline
Why does using --help do this?
- Lingua principale
- C#
- Stelle
- 4.8k
- Fork
- 478
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Out 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 ""
-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 ""
-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(args);
parserResult.WithParsed(options => OnSuccessfulParse(options));
parserResult.WithNotParsed(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:
```
///
/// Creates a new instance of the class,
/// automatically handling verbs or options scenario.
///
/// The containing the instance that collected command line arguments parsed with class.
/// The maximum width of the display.
///
/// An instance of class.
///
/// This feature is meant to be invoked automatically by the parser, setting the HelpWriter property
/// of .
public static HelpText AutoBuild(ParserResult parserResult, int maxDisplayWidth = DefaultMaximumLength)
{
if (parserResult.Tag != ParserResultType.NotParsed)
throw new ArgumentException("Excepting NotParsed type.", "parserResult");
var errors = ((NotParsed)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().Single();
var pr = new NotParsed(TypeInfo.Create(err.Type), Enumerable.Empty());
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?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.