Skip to content

CLI参数解析错误:--text / -t 无法接受以 "-" 开头的字符串(invalid boolean value) #69

@Qaraku

Description

@Qaraku

主要问题

该工具运行如下命令时,出现解析失误

~ $ kd --text="- something"
Incorrect Usage: invalid boolean value "- something" for -text: parse error

NAME:
   kd - A crystal clean command-line dictionary.

USAGE:
   kd [global options]

VERSION:
   v0.0.14

AUTHOR:
   kmz <valesail7@gmail.com>

GLOBAL OPTIONS:
   --text TEXT, -t TEXT     translate long query TEXT with e.g. --text="Long time ago" 翻译长句
   --json                   output as JSON
   --nocache, -n            don't use cached result 不使用本地词库,查询网络结果
   --theme value, -T value  choose the color theme for current query 选择颜色主题,仅当前查询生效 (default: temp)
   --force, -f              forcely update (only after --update) 强制更新(仅搭配--update)
   --speak, -s              (experimental) read the word with speaker program 单词朗读
   --daemon                 ensure/start the daemon process 启动守护进程
   --update                 check and update kd client 更新kd的可执行文件
   --generate-config        generate config sample 生成配置文件,Linux/Mac默认地址为~/.config/kd.toml,Win为~\kd.toml
   --edit-config            edit configuration file with the default editor 用默认编辑器打开配置文件
   --help, -h               show help
   --version, -v            print the version
☣ ERROR: invalid boolean value "- something" for -text: parse error 

预期行为

--text / -t 应当接受任意字符串作为参数值,包括以 '-' 开头的文本。程序不应把用户传入的文本误解析为布尔值或其它选项。

运行环境

操作系统:Arch Linux
软件版本:kd version v0.0.14 (来自AUR)
使用shell:zsh

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions