繁体   English   中英

带有空白的Ruby Thor选项

[英]Ruby Thor options with white space

对于我正在做的作业,我需要有一个选项“ --format oneline”,其中我的输出格式为一行。

我已成功完成此操作,但前提是我使用了--formatoneline(无空格)。 如果我包含空格,它将选项分成2个参数[“ format”,“ oneline”]。

我想知道这里如何处理空白字符,因为分配要求非常特殊的格式。

这是使用ruby和Thor模块进行编码的。

谢谢!

插口

您可以为选项指定:type 在这里看看

method_option :format, type: :string

然后您可以检查是否存在--format oneline

if options[:format] == 'oneline'
   # puts smth
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM