I am trying to create a executable ruby script using Thor.
I have defined the options for my task. So far I have something like this
class Command < Thor
desc "csv2strings CSV_FILENAME", "convert CSV file to '.strings' file"
method_option :langs, :type => :hash, :required => true, :aliases => "-L", :desc => "languages to convert"
...
def csv2strings(filename)
...
end
...
def config
args = options.dup
args[:file] ||= '.csvconverter.yaml'
config = YAML::load File.open(args[:file], 'r')
end
end
When csv2strings
is called without arguments, I would like the config task to be invoked, which would set the option :langs
.
I haven't yet found a good way to do it.
Any help will be appreciated.
csv2strings
method options method was called after the required check. So if you have any solution to improve that just let me know – Ragan