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

Behaviour of Command.Proxy and forwarding arguments #52

Closed
njmaeff opened this issue Nov 14, 2020 · 1 comment
Closed

Behaviour of Command.Proxy and forwarding arguments #52

njmaeff opened this issue Nov 14, 2020 · 1 comment

Comments

@njmaeff
Copy link

njmaeff commented Nov 14, 2020

I am looking for a way to forward arguments to another command and only arguments that do not exist already on the defined command. Currently proxy will forward all arguments passed into the command and will not register flags passed into the command. Is this the expected behavour of Proxy? Is there another way for this to work? In the below example, the assertion is what I am looking for. This test will fail.

it(`proxy behaviour`, async () => {
    const output = await runCli(() => {
        class CommandA extends Command {
            @Command.Boolean('-a')
            a = false
            @Command.Proxy()
            args: string[] = []

            @Command.Path('p1')
            async execute() {
                log(this, ['a', 'args'])
            }
        }

        return [
            CommandA,
        ];
    }, [
        "p1", "-a", "-b", "positionalArg"
    ]);

    expect(output).to.equal(
        [
            `Running CommandA`,
            `true`,
            `["-b","positionalArg"]\n`
        ].join('\n')
    );
})
@njmaeff njmaeff changed the title Behaviour of Command.Proxy Behaviour of Command.Proxy and forwarding arguments Nov 14, 2020
@arcanis
Copy link
Owner

arcanis commented Nov 21, 2020

You need to pass the non-proxy options before the last static path component (ie -a p1 -b positionalArgs), otherwise the expected behavior becomes ambiguous and Clipanion resolves it by forwarding the argument.

@arcanis arcanis closed this as completed Nov 21, 2020
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

2 participants