Class: Fropy::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/fropy/cli.rb

Constant Summary collapse

Doc =
"Fropy - Process memory and cpu time benchmarker\n\nUsage:\n  fropy <command> [--dev-null] [--poll-interval=POLL]\n  fropy -h | --help\n  fropy -v | --version\n\nOptions:\n  -h --help            Show this help\n  --dev-null           Redirect output of the command to /dev/null\n  --poll-interval=POLL Time in seconds to poll memory usage and process\n                       status [default: 0.05]\n"

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fropy/cli.rb', line 18

def initialize(argv)
  require "pp"
  begin
    options = Docopt::docopt(Doc)
    if options["-v"] || options["--version"]
      puts "Fropy #{Fropy::VERSION}"
      exit
    end
    benchmark = Benchmark.new options["<command>"],
               poll_interval: options["--poll-interval"].to_f,
                    dev_null: options["--dev-null"]
    benchmark.measure
  rescue Docopt::Exit => e
    puts e.message
  end
end