my_gem hello name1 name2 name3 give me a
my_gem hello requires at least 1 argument: my_gem hello name
Should I just parse them and separate the arguments with a delimeter?
e.g
my_gem hello name1,name2,name3,nameN
In the file it would look like
class MyCLI < Thor
desc "hello NAMES", "say hello to names"
def hello(names)
say "hello #{names.split(',')}"
end
end
Or is there anyway to do this?
Yes, there is another way of doing this.
require 'thor'
class TestApp < Thor
desc "hello NAMES", "long desc"
def hello(*names)
say "hello #{names.join('; ')}"
end
end
And it can be called like this:
$ thor test_app:hello first second third
hello first; second; third
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With