Module: Kamisaku::ArgParser

Defined in:
lib/kamisaku/arg_parser.rb

Class Method Summary collapse

Class Method Details

.parse! ⇒ Object

Raises:

  • (OptionParser::MissingArgument)


7
8
9
10
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
# File 'lib/kamisaku/arg_parser.rb', line 7

def self.parse!
  options = {}

  OptionParser.new do |parser|
    parser.on("--html-debug-path HTML_OUTPUT") do |html_output|
      options[:html_output] = html_output
    end

    parser.on("-c", "--yaml-file INFO", "Require the INFO") do |yaml_file|
      options[:yaml_file] = yaml_file
    end

    parser.on("-o", "--pdf-file OUTPUT", "Require the OUTPUT") do |pdf_file|
      options[:pdf_file] = pdf_file
    end

    parser.on("-k", "--category CATEGORY", "Provide the TEMPLATE name") do |category|
      options[:category] = category
    end

    parser.on("-t", "--template TEMPLATE", "Provide the TEMPLATE name") do |template|
      options[:template] = template
    end
  end.parse!

  raise OptionParser::MissingArgument.new("-c") if options[:yaml_file].nil?
  raise OptionParser::MissingArgument.new("-o") if options[:pdf_file].nil?

  options
end