Class: SensuRunCheck::CLI
- Inherits:
-
Object
- Object
- SensuRunCheck::CLI
- Defined in:
- lib/sensu-run-check/cli.rb
Class Method Summary collapse
-
.read(arguments = ARGV) ⇒ Hash
Parse CLI arguments using Ruby stdlib ‘optparse`.
Class Method Details
.read(arguments = ARGV) ⇒ Hash
Parse CLI arguments using Ruby stdlib ‘optparse`. This method provides SensuRunCheck with process options and can provide users with information, such as the SensuRunCheck version.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sensu-run-check/cli.rb', line 11 def self.read(arguments=ARGV) = {} optparse = OptionParser.new do |opts| opts.on("-h", "--help", "Display this message") do puts opts exit end opts.on("-V", "--version", "Display version") do puts VERSION exit end opts.on("-c", "--config FILE", "Sensu JSON config FILE") do |file| [:config_file] = file end opts.on("-d", "--config_dir DIR[,DIR]", "DIR or comma-delimited DIR list for Sensu JSON config files") do |dir| [:config_dirs] = dir.split(",") end opts.on("-e", "--extension_dir DIR", "DIR for Sensu extensions") do |dir| [:extension_dir] = dir end opts.on("-r", "--run_check CHECK", "CHECK to run") do |check| [:run_check] = check end opts.on("-l", "--list_checks", "List all defined checks") do [:list_checks] = true end opts.on("-R", "--run_all_checks", "Run all defined checks") do [:run_all_checks] = true end end optparse.parse!(arguments) end |