Module: Jira::Auto::Tool::CommonOptions

Defined in:
lib/jira/auto/tool/common_options.rb

Constant Summary collapse

DISPLAY_HELP_OPTION =
"--help"

Class Method Summary collapse

Class Method Details

.add(tool, parser) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/jira/auto/tool/common_options.rb', line 11

def self.add(tool, parser)
  ::ARGV << DISPLAY_HELP_OPTION if ARGV.empty?

  parser.section_header "Common"

  add_help_banner_and_options(parser)
  add_version_options(parser, tool)
end

.add_help_banner_and_options(parser) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/jira/auto/tool/common_options.rb', line 20

def self.add_help_banner_and_options(parser)
  parser.banner = "    Usage: \#{File.basename($PROGRAM_NAME)} [options]*\n  EOBANNER\n\n  parser.on(\"-h\", DISPLAY_HELP_OPTION, \"Print this help\") do\n    Kernel.puts parser\n    Kernel.exit 1\n  end\nend\n"

.add_version_options(parser, tool) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/jira/auto/tool/common_options.rb', line 31

def self.add_version_options(parser, tool)
  parser.on("-v", "--version", "Print the version") do
    Kernel.puts tool.class::VERSION

    Kernel.exit 1
  end
end