Module: HTTPDisk::Grep::Args
- Defined in:
- lib/httpdisk/grep/args.rb
Class Method Summary collapse
-
.slop(args) ⇒ Object
Slop parsing.
Class Method Details
.slop(args) ⇒ Object
Slop parsing. This is broken out so we can run without require ‘httpdisk’.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/httpdisk/grep/args.rb', line 9 def self.slop(args) slop = Slop.parse(args) do |o| o. = "httpdisk-grep [options] pattern [path ...]" o.boolean "-c", "--count", "suppress normal output and show count" o.boolean "-h", "--head", "show req headers before each match" o.boolean "-s", "--silent", "do not print anything to stdout" o.boolean "--version", "show version" do puts "httpdisk-grep #{HTTPDisk::VERSION}" exit end o.on "--help", "show this help" do puts o exit end end raise Slop::Error, "" if args.empty? raise Slop::Error, "no PATTERN specified" if slop.args.empty? slop.to_h.tap do _1[:pattern] = slop.args.shift _1[:roots] = slop.args end end |