I think you are looking for a way to set configuration options via the command line and via a configuration file.
Here is an example from the foreman gem.
def options
original_options = super
return original_options unless File.exists?(".foreman")
defaults = ::YAML::load_file(".foreman") || {}
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
end
It overrides the options
method and merges values from a configuration file into the original options hash.
In your case, the following might work:
def csv2strings(name)
# do something with options
end
private
def options
original_options = super
filename = original_options[:file] || '.csvconverter.yaml'
return original_options unless File.exists?(filename)
defaults = ::YAML::load_file(filename) || {}
defaults.merge(original_options)
# alternatively, set original_options[:langs] and then return it
end
(I recently wrote a post about Foreman on my blog that explains this in more detail.)