commandlineparser / commandlineparser/commandline

unable to set default value using Uri

Offen
#708 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C#
Sterne
4.8k
Forks
478
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

trying to be able to run an app like this:
consoleApp.exe
or
consoleApp.exe http://someOtherUri.invalid:1234

i can get the default value to work using a string:
class Options{
[Value(0,
Default = "http://someUri.invalid:1234"
)]
public string OptionalUri { get;set;}
}

but not using a Uri as its type.
class Options{
[Value(0,
Default = "http://someUri.invalid:1234"
)]
public Uri OptionalUri { get;set;}
}

static void Main(string[] args)
{
CommandLine.Parser.Default.ParseArguments(args)
.WithParsed(Run)
.WithNotParsed(HandleParseError);
}
static void Run(Options options)
{
//Uri u = options.OptionalUri;
Uri u = new Uri(options.OptionalUri); // possible parseerrors, should've been handled in commandlineparser
}

then i get
Error setting value to option '': Check if Option or Value attribute values
are set properly for the given type.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.