Skip to content

Instantly share code, notes, and snippets.

@basicxman
Created August 21, 2011 05:54
Show Gist options
  • Select an option

  • Save basicxman/1160213 to your computer and use it in GitHub Desktop.

Select an option

Save basicxman/1160213 to your computer and use it in GitHub Desktop.
--someboolean
--someoption "Foo bar baz."
--someotheroption "bar."
# I wanted to have a configuration file for my Slop options,
# but Slop doesn't support this by default, anything specified
# in ARGV should have higher priority over the config file.
class Slop
alias :option_core :option
def option(*args, &block)
args << {} unless args.last.is_a? Hash
key = (args.first.is_a? Symbol and args[1].is_a? Symbol) ? args[1] : args.first
args.last[:default] = $default[key] if $default.has_key? key
return option_core(*args, &block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment