Thor 是否抱怨过 Ruby 命令行应用程序中拼写错误的选项?
是否可以让 Thor 抱怨拼写错误/无法识别的命令行选项?
示例:
maid --slient # Oops! Misspelled. It should give a warning or usage info.
maid --silent # Do the behavior I programmed for the "silent" option.
Thor 确实很好,但如果它只是忽略它不知道如何处理的输入,那么对我来说就没有太大帮助。 Maid 还可以选择指定 Maid 规则文件,如下所示:
maid --rules=rules.rb # Good
maid -r rules.rb # Short version
maid rules.rb # Oops! That's not valid. It should give a warning or usage info.
在上述两种情况下,我该怎么做才能让 Thor 抱怨?
Maid gem 的代码位于 GitHub 上: http://github.com/benjaminoakes/maid
Is it possible to have Thor complain about misspelled/unrecognized command line options?
Example:
maid --slient # Oops! Misspelled. It should give a warning or usage info.
maid --silent # Do the behavior I programmed for the "silent" option.
Thor is really nice, but it isn't too helpful for me if it just ignores input it doesn't know how to handle. Maid also has an option to specify a file of Maid rules like so:
maid --rules=rules.rb # Good
maid -r rules.rb # Short version
maid rules.rb # Oops! That's not valid. It should give a warning or usage info.
What can I do to make Thor complain in the two cases above?
The code for the Maid gem is on GitHub at http://github.com/benjaminoakes/maid
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我收到了 Yehuda Katz 的一条推文。 (再次感谢!)这是解决方案:
我测试并将其添加到我的项目中。新行为如下:
请参阅 GitHub 上的完整代码 。
I got a tweet from Yehuda Katz. (Thanks again!) Here's the solution:
I tested and added it into my project. Here's the new behavior:
See the full code on GitHub.