class CDQ::CommandLine

Constants

HELP_TEXT

Attributes

singleton_options_passed[R]

Public Class Methods

run_all() click to toggle source
# File lib/cdq/cli.rb, line 35
def self.run_all

  actions = { "init" => InitAction, "create" => CreateAction }

  cli = self.new
  opts = cli.option_parser
  opts.order!
  action = ARGV.shift

  if actions[action]
    actions[action].new.run
  elsif !cli.singleton_options_passed
    puts opts
  end

end

Public Instance Methods

option_parser(help_text = HELP_TEXT) click to toggle source
# File lib/cdq/cli.rb, line 19
def option_parser(help_text = HELP_TEXT)
  OptionParser.new do |opts|
    opts.banner = help_text

    opts.on("-v", "--version", "Print Version") do
      @singleton_options_passed = true
      puts CDQ::VERSION
    end

    opts.on("-h", "--help", "Show this message") do
      @singleton_options_passed = true
      puts opts
    end
  end
end