diff options
author | Lee Jarvis <lee@jarvis.co> | 2011-04-24 09:53:19 +0100 |
---|---|---|
committer | Lee Jarvis <lee@jarvis.co> | 2011-04-24 09:53:19 +0100 |
commit | 51cbd1ebaada79c5ffe28445e4a550b08d4f6d51 (patch) | |
tree | e35cf9ddd015928062d756ef61ac305cf7158c90 /README.md | |
parent | 7e9fb614ba2a016a6aa97f85b78ad5f061b29394 (diff) | |
download | slop-51cbd1ebaada79c5ffe28445e4a550b08d4f6d51.tar.gz |
Revert "add :as => Dir option for globbing directories"
This is actually pointless as the shell would have already expanded the
glob. Shame!
It could still be used to non shell parsing, but I dont want to create
confusing
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 28 |
1 files changed, 2 insertions, 26 deletions
@@ -127,8 +127,8 @@ Here's what we'll get back :password=>"hello there" } -Events ------- +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: @@ -233,30 +233,6 @@ What would Slop be if it didn't know what ranges were? # ARGV is `--range 1..10` or 1-10, or 1,10 (yes Slop supports them all) opts[:range].to_a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -Directories ------------ - -Would you like to run a glob on a directory? Sure you can do it like this: - - opts = Slop.parse do - on :d, :dir, 'A directory glob string', true do |str| - files = Dir.glob(str) - end - end - -Which is great, but it would be nicer if we didn't **need** that event block. -Luckily, we don't: - - opts = Slop.parse do - on :d, :dir, 'A directory glob string', true, :as => Dir - end - - # --dir /home/injekt/*.rb - opts[:d] #=> ["/home/injekt/foo.rb", "/home/injekt/etc.rb"] - -You can also add the `:basename => true` option which will ask Slop to return -an Array of filenames rather than an Array of paths. - Ugh, Symbols ------------ |