Class: Yardstick::CLI
- Inherits:
-
Object
- Object
- Yardstick::CLI
- Defined in:
- lib/yardstick/cli.rb
Overview
Handle the yardstick command line interface
Class Method Summary collapse
-
.display_exit(message) ⇒ undefined
private
Display a message and exit.
-
.option_parser(options) ⇒ Yardstick::OptionParser
private
Return an OptionParser instance for the command-line app.
-
.parse_options(args) ⇒ Array(Array<String>, Hash)
private
Parse the options provided from the command-line.
-
.run(*args) ⇒ Yardstick::MeasurementSet
Parse the command line options, and run the command.
Class Method Details
.display_exit(message) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Display a message and exit
70 71 72 73 |
# File 'lib/yardstick/cli.rb', line 70 def self.display_exit() puts .to_str exit end |
.option_parser(options) ⇒ Yardstick::OptionParser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return an OptionParser instance for the command-line app
55 56 57 58 59 60 |
# File 'lib/yardstick/cli.rb', line 55 def self.option_parser() opts = OptionParser.new opts.on_tail('-v', '--version', 'print version information and exit') { display_exit("#{opts.program_name} #{Yardstick::VERSION}") } opts.on_tail('-h', '--help', 'display this help and exit') { display_exit(opts.to_s) } opts end |
.parse_options(args) ⇒ Array(Array<String>, Hash)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parse the options provided from the command-line
37 38 39 40 41 42 43 44 |
# File 'lib/yardstick/cli.rb', line 37 def self.(args) args << '--help' if args.empty? = {} option_parser().parse!(args) [ args, ] rescue OptionParser::InvalidOption => error display_exit(error.) end |
.run(*args) ⇒ Yardstick::MeasurementSet
Parse the command line options, and run the command
22 23 24 25 26 |
# File 'lib/yardstick/cli.rb', line 22 def self.run(*args) measurements = Yardstick.measure(*(args)) measurements.puts measurements end |