Class: Spex::CLI
- Inherits:
-
Object
- Object
- Spex::CLI
- Defined in:
- lib/spex/cli.rb
Instance Method Summary collapse
-
#initialize(args = []) ⇒ CLI
constructor
A new instance of CLI.
- #options ⇒ Object
- #parser ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args = []) ⇒ CLI
Returns a new instance of CLI.
7 8 9 |
# File 'lib/spex/cli.rb', line 7 def initialize(args = []) @args = args end |
Instance Method Details
#options ⇒ Object
11 12 13 |
# File 'lib/spex/cli.rb', line 11 def @options ||= OpenStruct.new end |
#parser ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/spex/cli.rb', line 15 def parser @parser ||= OptionParser.new do |opts| opts. = "spex [OPTIONS] DEFINITION_FILE" opts.separator "\nOPTIONS:" opts.on_tail('--help', '-h', 'Show this message') do puts opts exit end opts.on('--describe', '-d', 'Describe DEFINITION_FILE') do .describe = true end opts.on('--checks', '-c', "List supported checks") do display_checks exit end end end |
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/spex/cli.rb', line 33 def run parser.parse!(@args) filename = @args.shift if !filename refuse "No definition file given" elsif !File.exist?(filename) refuse "Definition file not found: #{filename}" else accept(filename) end end |