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

自动重定向至子指令后选项无法自动赋值 #540

Closed
Tracked by #615
bsdayo opened this issue Feb 22, 2022 · 2 comments
Closed
Tracked by #615

自动重定向至子指令后选项无法自动赋值 #540

bsdayo opened this issue Feb 22, 2022 · 2 comments

Comments

@bsdayo
Copy link

bsdayo commented Feb 22, 2022

Describe the bug

首先十分感谢采纳之前在 #476 的建议!

但出现了新的问题,即定义选项后,无法自动根据缩写给选项变量赋值

文档中所说,使用 .option('-a', 'alpha') 定义选项后,应该在使用 -a 选项时,自动为 options.alpha 赋值

但在调用指令 /cmd subcmd -a 时发现并没有为 alpha 赋值,反而是直接赋给了 a

console.log(JSON.stringify(options))

{"a":true}

而在父子指令中加上 ./cmd.subcmd -a)后又恢复正常,为 options.alpha 赋上了 true

console.log(JSON.stringify(options))

{"alpha":true}

Steps to reproduce

定义父指令 cmd 并添加子指令 subcmd,然后为 subcmd 添加选项 ('alpha', '-a')

分别使用 cmd subcmd -acmd.subcmd -a 进行测试

Expected behavior

重定向至子指令时自动根据缩写给选项变量赋值

Screenshots

No response

Versions

  • OS: Windows 10
  • Platform: Onebot
  • Node version: 16.13.2
  • Koishi version: 4.2.1

Additional context

No response

@bsdayo bsdayo added the bug BUG label Feb 22, 2022
@bsdayo
Copy link
Author

bsdayo commented Feb 23, 2022

发现了另一个问题(

定义alpha和beta两个选项

ctx
  .command('cmd')
  .subcommand('.subcmd')
  .option('alpha', '-a')
  .option('beta', '-b')

这时不使用自动重定向(cmd.subcmd --alpha --beta

console.log(JSON.stringify(options))

{"alpha":true,"beta":true}

使用自动重定向(cmd subcmd --alpha --beta)会出现

console.log(JSON.stringify(options))

{"alpha":"--beta"}

@shigma
Copy link
Member

shigma commented Feb 23, 2022

嗯确实是需要解决的 Bug。

@shigma shigma added this to the 4.6 milestone Apr 5, 2022
@shigma shigma modified the milestones: 4.6, 4.7 Apr 21, 2022
Anillc added a commit to Anillc/koishi that referenced this issue May 1, 2022
Anillc added a commit to Anillc/koishi that referenced this issue May 1, 2022
Anillc added a commit to Anillc/koishi that referenced this issue May 1, 2022
Anillc added a commit to Anillc/koishi that referenced this issue May 2, 2022
Anillc added a commit to Anillc/koishi that referenced this issue May 2, 2022
@shigma shigma closed this as completed in e5cb56b May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants