for an assignment I am doing I am required to have an option "--format oneline" where my output is formatted in one line.
I have successfully done this, but only if I use --formatoneline (without the white space). If I include the white space it seperates the option into 2 arguments ["format", "oneline"].
I'd like to know how to deal with the white space character here, as the assignment requires very specific formatting.
This is coded using ruby and the Thor Module.
Thanks!
Jack
You can specify :type
for an option. Take a look here.
method_option :format, type: :string
And then you can check if there is --format oneline
if options[:format] == 'oneline'
# puts smth
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.