mdub/clamp — pull request #19 by jordansissel (2012-04-16 21:20:40+00:00)
Title: Add env option values

As discussed in #17, here is my proposed patch adding environment variable support. Things covered:

* env values are subject to the same code paths as flag values are (the #foo_bar= methods)
* for `:flag` options, an env value of "1" is true, anything else is false
* added specs to verify functionality

Example:

```ruby
class Foo < Clamp::Command
option "--foo", "BAR", "HELLO", :env => "FOO"
option "--[no-]test", :flag, "HELLO", :env => "TEST"

def execute
p :foo => foo, :test? => test?
end
end

Foo.run(ARGV)
```

Output:

```
% FOO=hello ruby test.rb
{:foo=>"hello", :test?=>nil}
% FOO=hello ruby test.rb --foo bar
{:foo=>"bar", :test?=>nil}
% FOO=hello TEST=0 ruby test.rb --foo bar
{:foo=>"bar", :test?=>false}
% FOO=hello TEST=1 ruby test.rb --foo bar
{:foo=>"bar", :test?=>true}
% FOO=hello TEST=1 ruby test.rb --foo bar --no-test
{:foo=>"bar", :test?=>false}
```