README.md in slop-0.1.9 vs README.md in slop-0.2.0

- old
+ new

@@ -45,18 +45,35 @@ option(:v, :verbose, :default => false, :switch => true) option(:applicable_age, :default => 10, :switch => 20) end # without `-v` - s.value_for(:verbose) #=> false + s[:verbose] #=> false # using `-v` - s.value_for(:verbose) #=> true + s[:verbose] #=> true # using `--applicable_age` - s.value_for(:applicable_age) #=> 20 + s[:applicable_age] #=> 20 +Want these options back in a nice readable help string? Just call `Slop.to_s` +and Slop will return a nice indented option list. You can even add a banner to +the help text using the `banner` method like so: + + opts = Slop.new do + banner("Usage: foo [options]") + + opt(:n, :name, "Your name", true) + end + + puts opts + +Returns: + + Usage: foo [options] + -n, --name <name> Your name + Callbacks --------- If you'd like to trigger an event when an option is used, you can pass a block to your option. Here's how: @@ -78,11 +95,11 @@ you can pass the `:as` attribute to your option. s = Slop.parse("--age 20") do opt(:age, true, :as => Integer) # :int/:integer both also work end - s.value_for(:age) #=> 20 # not "20" + s[:age] #=> 20 # not "20" Smart ----- Slop is pretty smart when it comes to building your options, for example if you @@ -108,17 +125,17 @@ You can of course also parse lists into options. Here's how: s = Slop.parse("--people lee,injekt") do opt(:people, true, :as => Array) end - s.value_for(:people) #=> ["lee", "injekt"] + s[:people] #=> ["lee", "injekt"] You can also change both the split delimiter and limit s = Slop.parse("--people lee:injekt:bob") do opt(:people, true, :as => Array, :delimiter => ':', :limit => 2) end - s.value_for(:people) #=> ["lee", "injekt:bob"] + s[:people] #=> ["lee", "injekt:bob"] Contributing ------------ If you'd like to contribute to Slop (it's **really** appreciated) please fork