Skip to content
New issue

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

ICommandParameterSet not working with array Arguments #134

Open
jorgy343 opened this issue Mar 16, 2024 · 0 comments
Open

ICommandParameterSet not working with array Arguments #134

jorgy343 opened this issue Mar 16, 2024 · 0 comments

Comments

@jorgy343
Copy link

When a command is using an array arguments, Cocona sets all ICommandParameterSet parameters to null. This behavior only occurs when the argument is an array. When the argument is, for example, a string it works fine and the ICommandParameterSet parameters are appropriately initialized.

.net 8 with Cocona 2.2.0

Here is a simple app that demonstrates this issue:

using Cocona;
using System;

var builder = CoconaApp.CreateBuilder(args);
var app = builder.Build();

// testParameters will be null
app.AddCommand("command", (TestParameters testParameters, [Argument] string[] strs) =>
{
    Console.WriteLine(testParameters.Param);
    Console.WriteLine(testParameters.Switch);

    Console.WriteLine(strs);
});

await app.RunAsync();

public record class TestParameters(
    bool Param,
    bool Switch)
    : ICommandParameterSet;

Command is executed as such to display behavior:

command --param str1 str2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant