Class: Hivent::CLI::StartOptionParser
- Inherits:
-
Object
- Object
- Hivent::CLI::StartOptionParser
- Defined in:
- lib/hivent/cli/start_option_parser.rb
Instance Method Summary collapse
-
#initialize(command, argv) ⇒ StartOptionParser
constructor
A new instance of StartOptionParser.
- #parse ⇒ Object
- #validate_options ⇒ Object
Constructor Details
#initialize(command, argv) ⇒ StartOptionParser
Returns a new instance of StartOptionParser.
8 9 10 11 |
# File 'lib/hivent/cli/start_option_parser.rb', line 8 def initialize(command, argv) @command = command @argv = argv end |
Instance Method Details
#parse ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hivent/cli/start_option_parser.rb', line 13 def parse return @options if @options @options = {} parser = OptionParser.new do |o| o. = "Usage: hivent #{@command} [options]" o.on('-r', '--require PATH', 'File to require to bootstrap consumers') do |arg| @options[:require] = arg end end parser.parse(@argv) @options end |
#validate_options ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hivent/cli/start_option_parser.rb', line 32 def if @options[:require].nil? || !File.exist?(@options[:require]) puts <<-EOS.strip_heredoc ========================================================= Please point hivent to a Ruby file to load your consumers with -r FILE. ========================================================= EOS exit(1) end end |