Class: Yuzu::Command::ArgParser

Inherits:
Object
  • Object
show all
Defined in:
lib/yuzu/argparse.rb

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/yuzu/argparse.rb', line 26

def self.parse(args)
  options = OpenStruct.new
  options.output = :quiet    # :verbose, :debug

  option_parser = \
  OptionParser.new do |opts|
    opts.banner = ""

    opts.separator "Options"
    opts.separator ""

    opts.on("--verbose", "Run showing verbose output.") do
      options.output = :verbose
    end

    opts.on_tail("-h", "--help", "Show this help message.") do
      puts HELP_MESSAGE
      puts opts
      exit
    end

    opts.on_tail("-v", "--version", "Show version.") do
      puts Yuzu::Version::STRING
      exit
    end
  end

  option_parser.parse!(args)
  options

end