Module: Pocketwatch
- Defined in:
- lib/pocketwatch.rb,
lib/pocketwatch/version.rb,
lib/pocketwatch/watcher.rb
Defined Under Namespace
Classes: Watcher
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
-
.parse(args) ⇒ Hash
Parse an argument list for configuration options.
-
.start(args) ⇒ void
Parse the ARGV input and run the command watcher.
Class Method Details
.parse(args) ⇒ Hash
Parse an argument list for configuration options
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pocketwatch.rb', line 21 def self.parse(args) = {} parser = OptionParser.new do |opts| opts. = "Usage: pocketwatch [options] -- <command>" opts.on("-v", "--version", "Print the version number") do puts Pocketwatch::VERSION exit end opts.on("-n INTERVAL", Integer, "Length in seconds between command execution") do |v| unless v.positive? warn "Must provide a positive integer for the command execution interval." exit end [:interval] = v end end parser.parse!(args) end |
.start(args) ⇒ void
This method returns an undefined value.
Parse the ARGV input and run the command watcher.
11 12 13 14 |
# File 'lib/pocketwatch.rb', line 11 def self.start(args) = parse(args) Watcher.new(args.join(" "), ).run end |