我正在用Thor写一个CLI宝石。现在我有两个名字的子命令,我想要连字符。但我无法弄清楚如何做到这一点。
这是主要的课程
module CLI
class Base < Thor
desc "api-token COMMAND", "Configure the API token"
subcommand "api-token", ApiToken
这是子命令类
module CLI
class ApiToken < Thor
include Shared
namespace "api-token"
子命令显示在主help
输出中,如果我输入
$ bundle exec bin/cli help api-token
它显示了子命令操作的正确输出。所以至少有些东西在连接。
但是当我尝试使用命令时,这就是我所看到的
$ bundle exec bin/cli api-token set
> Could not find command "api-token".
如果我用一个单词或使用下划线,该命令工作正常,但我真的更喜欢连字符。
答案 0 :(得分:2)
不需要map
,只需
class Test < Thor
desc 'howto-dash', "dash in command name"
def howto_dash
puts "dashing through the snow"
end
end
输出:
> thor list
test
----
thor test:howto-dash # dash in command name
答案 1 :(得分:0)