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

Option.Rest() & Option.Proxy() can not be used together. #163

Open
magicdawn opened this issue Jun 30, 2024 · 0 comments
Open

Option.Rest() & Option.Proxy() can not be used together. #163

magicdawn opened this issue Jun 30, 2024 · 0 comments

Comments

@magicdawn
Copy link

export class FooCommand extends Command {
  static paths = [['foo']]

  idList = Option.Rest({
    name: 'id list',
  })

  extraArgs = Option.Proxy()

  async execute() {
  }
}

when exec cli foo id1 id2 -- -p ALL error logs:

Error: Infinite lists cannot be declared multiple times in the same command
    at CommandBuilder.addRest (/tmp/demo/node_modules/.pnpm/[email protected][email protected]/node_modules/clipanion/lib/core.js:564:19)
    at CommandBuilder.addProxy (/tmp/demo/node_modules/.pnpm/[email protected][email protected]/node_modules/clipanion/lib/core.js:572:14)
    at definition (/tmp/demo/node_modules/.pnpm/[email protected][email protected]/node_modules/clipanion/lib/advanced/options/Proxy.js:24:21)
    at Cli.register (/tmp/demo/node_modules/.pnpm/[email protected][email protected]/node_modules/clipanion/lib/advanced/Cli.js:139:13)
    at <anonymous> (/tmp/demo/src/cli.ts:31:5)
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

and I noticed that Option.Proxy() will consume all args after last path component.

It would be nice to support explicit proxied args, separated by --.

and In my case, assign components before -- to Option.Rest() [id1, id2], and after -p ALL to Option.Proxy(), so things like for(id of bvidList) exec(other-command ${id} ${extraArgs}) can be done.


Current if only use Option.Rest() with cli foo id1 id2 -- -p ALL, idList will be [ 'id1', 'id2', '-p', 'ALL' ], there is no clear remark to manual split them into [id1, id2] & [-p, ALL]

Thanks for your works anyway~

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