We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
I have the following command line parameters:
static void Main(string[] args) { args = new string[] { "e", "myuser", "mypass", "2020.01.01 01:00", "2021.01.01 01:00" }; var rootCommand = new RootCommand(); var export = new Command("export", "Export"); rootCommand.Add(export); export.AddAlias("e"); var userNameArg = new Argument<string>("username"); var passwordArg = new Argument<string>("password"); var sdateArg = new Argument<DateTime>("sdate"); var edateArg = new Argument<DateTime>("edate"); edateArg.Arity = ArgumentArity.ZeroOrOne; var fairwayArg = new Argument<string>("fw"); fairwayArg.Arity = ArgumentArity.ZeroOrOne; var startRkmArg = new Argument<double>("srk"); startRkmArg.Arity = ArgumentArity.ZeroOrOne; var endRkmArg = new Argument<double>("erk"); endRkmArg.Arity = ArgumentArity.ZeroOrOne; export.AddArgument(userNameArg); export.AddArgument(passwordArg); export.AddArgument(sdateArg); export.AddArgument(edateArg); export.AddArgument(fairwayArg); export.AddArgument(startRkmArg); export.AddArgument(endRkmArg); export.SetHandler(context => { string userName = context.ParseResult.GetValueForArgument(userNameArg); string password = context.ParseResult.GetValueForArgument(passwordArg); var sDate = context.ParseResult.GetValueForArgument(sdateArg); var eDate = context.ParseResult.GetValueForArgument(edateArg); string fairway = context.ParseResult.GetValueForArgument(fairwayArg); double startRkm = context.ParseResult.GetValueForArgument(startRkmArg); double endRkm = context.ParseResult.GetValueForArgument(endRkmArg); Console.WriteLine($""" user: {userName} pass: {password} sdate: {sDate} edate: {eDate} fw: {fairway} srk: {startRkm} erk: {endRkm} """); Console.ReadLine(); }); var parser = new CommandLineBuilder(rootCommand).UseDefaults().Build(); parser.Invoke(args); }
When I run this code the result will be:
user: myuser pass: mypass sdate: 2020. 01. 01. 1:00:00 edate: 2021. 01. 01. 1:00:00 fw: mypass srk: 0 erk: 0
So the 2nd "mypass" argument will be applied to the "fw" argiment. Why? How can I solve this?
I'm using the currelty latest version (2.0.0-beta4.22272.1)
Thanks, Gábor
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
I have the following command line parameters:
When I run this code the result will be:
So the 2nd "mypass" argument will be applied to the "fw" argiment. Why? How can I solve this?
I'm using the currelty latest version (2.0.0-beta4.22272.1)
Thanks,
Gábor
The text was updated successfully, but these errors were encountered: