diff options
author | Lee Jarvis <lee@jarvis.co> | 2011-04-24 09:42:26 +0100 |
---|---|---|
committer | Lee Jarvis <lee@jarvis.co> | 2011-04-24 09:42:26 +0100 |
commit | 7e9fb614ba2a016a6aa97f85b78ad5f061b29394 (patch) | |
tree | 1a5e71d7a7b25b94da3cc852ca8913674efc7f87 /README.md | |
parent | c776341d2a5c25df8cb5f2e5249487e910350158 (diff) | |
download | slop-7e9fb614ba2a016a6aa97f85b78ad5f061b29394.tar.gz |
added README doc for :as => Dir
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -233,6 +233,30 @@ 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 ------------ |