Skip to content
Giacomo Stelluti Scala edited this page Aug 7, 2015 · 12 revisions

IMPORTANT NOTE: This wiki refers to latest stables, if a beta version is available in github master branch please refer to Latest Version.

Multi-Culture Support

The parser is culture-aware. The args[] array passed to ParseArguments<T>(...) is a string array, so when the parser loads data into target instance every string undergoes a conversion.

Now suppose you define a target class like this:

class Options {
  [Option('v', "value")]
  public double SomeValue { get; set; }
}

If your system use a dot as decimal separator and you type the following command line:

$ app -v 10,4

the parsing process will fail.

If you want that parsing occurs with a particular culture, just set desired CultureInfo in settings instance.

var parser = new CommandLine.Parser(with => with.ParsingCulture = new CultureInfo("it-IT"));

Please note that default behavior can change in future versions, so I suggest you to always explicit your culture preference.

Remarks: CommandLine.Parser.Default default singleton uses CultureInfo.InvariantCulture.