I am building a generator in Ruby-on-Rails and was wondering if it's possible to ask for a required argument with Thor . Or if there's a decent workaround. Right now I'm just raising an exception:
@foo = ask('[Required] Enter Foo:')
raise 'Required argument missing' unless (@foo).present?
A workaround could be:
loop do
@foo = ask('[Required] Enter Foo:')
break if @foo.present?
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.