【问题标题】:Script error message: "Could not find command in namespace"脚本错误消息:“在命名空间中找不到命令”
【发布时间】:2015-01-18 18:45:52
【问题描述】:

我已将其放入我的 Foo.thor:

class Foo < Thor
  desc 'hello', 'prints hello'
  def hello
    puts 'hello'
  end
end

Foo.start(ARGV)

但是在执行 'thor foo:hello' 时,我收到以下错误消息:

Could not find command "foo:hello" in "foo" namespace.

连同输出“你好”

所以“你好”的输出看起来是正确的,但是前一行的错误消息让我想知道是否有问题。

我可以摆脱那个错误信息吗?

【问题讨论】:

    标签: ruby command-line thor


    【解决方案1】:

    不要在文件中使用 Foo.start(ARGV)。你不需要这条线。

    【讨论】:

    • 是的,即使文档说:“在本指南的其余部分中,我将假设您在当前目录中有一个名为 cli 的文件,看起来像这样”,然后显示一个启动命令。删除它!
    【解决方案2】:

    事实证明,我不需要最后一行。没有它,错误消息就消失了!

    【讨论】:

      猜你喜欢
      • 2022-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-19
      • 2012-10-13
      • 1970-01-01
      相关资源
      最近更新 更多