From 8353e4c61a2138c0d21228d419fe47bc346baad1 Mon Sep 17 00:00:00 2001 From: Joshua Conero Date: Thu, 28 Sep 2023 15:29:00 +0800 Subject: [PATCH] pref(cmd/uymas): test add dynamic option test. --- ChangeLog_zh-CN.md | 1 + bin/arg.go | 2 -- cmd/uymas/defaultApp.go | 9 +++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog_zh-CN.md b/ChangeLog_zh-CN.md index ef443ad..58adf4e 100644 --- a/ChangeLog_zh-CN.md +++ b/ChangeLog_zh-CN.md @@ -47,6 +47,7 @@ - feat: 新增中国传统的天干地支与年份的关系,实现年份的计算 - **cmd/uymas** - pref: 优化默认命令并显示应用的名称 + - pref: test 子命令添加动态参数获取 - feat: 新增命令 "digit/dg" 用于数字与中文大小写数字转换 - feat: 新增命令"hash"实现读取文件的hash,用于文件比较 - feat: 新增命令“ganz"实现年份的干支纪元法计算 diff --git a/bin/arg.go b/bin/arg.go index 673b857..f983d55 100644 --- a/bin/arg.go +++ b/bin/arg.go @@ -439,8 +439,6 @@ func NewCliCmd(args ...string) *Arg { } // NewCliCmdByString construction of `Arg` by string -// -// @todo notice: `--test-string="Joshua 存在空格的字符串 Conero"` 解析失败 func NewCliCmdByString(ss string) *Arg { return NewCliCmd(butil.StringToArgs(ss)...) } diff --git a/cmd/uymas/defaultApp.go b/cmd/uymas/defaultApp.go index 5c97e48..6070c9b 100644 --- a/cmd/uymas/defaultApp.go +++ b/cmd/uymas/defaultApp.go @@ -90,9 +90,18 @@ func (c *defaultApp) Test() { fmt.Printf(" NextLing : %#v \n", cc.NextList()) fmt.Printf(" Args : %#v \n", os.Args[1:]) + // var + varName := cc.ArgRaw("var", "v") + if varName != "" { + fmt.Printf(" Var : %s => %s \n", varName, cc.ArgRaw(varName)) + fmt.Printf(" Var/Raw : %s => %#v \n", varName, cc.Arg(varName)) + } + fmt.Println() fmt.Printf(" %v \n", getSpendStr()) fmt.Println() + fmt.Println() + fmt.Println("输入命令 “--var,-v $name” 可用于读取 $name 的option参数") } // Repl REPL