Skip to content

Unable to parse TimeSpan given from the FormatCommandLine #579

@Qrtic

Description

@Qrtic

It seems like starting from version 2.7 a bug in unparsing of TimeSpan options appeared.
Version 2.6 unparsing results in unquoted timespan value (i.e. 00:01:00), whereas version's 2.7 or 2.7.82 is quoted (i.e. "00:01:00"), which couldn't be parsed.
Was it intended to be quoted and it should be properly parsed then?

Here's a sample code, which describes an issue.

var args = Parser.Default.FormatCommandLine(new Options
            {
                Interval = TimeSpan.FromMinutes(1)
            }).Split(' ');
// results in quoted TimeSpan: --interval "00:01:00"
// which throws on parsing with CommandLine.BadFormatConversionError
Parser.Default.ParseArguments<Options>(args)
    .MapResult(
        options => options, 
        errs => throw new Exception(errs.First().ToString()));

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions