commandlineparser / commandlineparser/commandline

Values are not set properly wit multiple bool arguments

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

Beschreibung

I am passing 2 bool options, one on true and the other on false
But after being convert to the class all are true;

static void Main(string[] args)
{
args = new[] {"-p 88", "-t true", "-s false"};
var parseResult = Parser.Default.ParseArguments(args)
.WithParsed(o =>
{
Console.WriteLine($"PartnerId: -p {o.PartnerId}");
Console.WriteLine($"Test: -t {o.Test.ToString().ToLower()}");
Console.WriteLine($"SuppressEmail: -s {o.SuppressEmail.ToString().ToLower()}");
}
);
}
}

public class Options
{
[Option('p', "partnerId", Required = true, HelpText = "p = PartnerId")]
public int PartnerId { get; set; }

[Option('t', "test", HelpText = "Allows the app to be run on test mode, using only the allowed accounts")]
public bool Test { get; set; }

[Option('s', "suppressEmail", HelpText = "The app will not send the email to Post Up")]
public bool SuppressEmail { get; set; }
}

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.