Class: Gitomator::ScriptUtil::DefaultOptionParser

Inherits:
Trollop::Parser
  • Object
show all
Defined in:
lib/gitomator/util/script_util.rb

Overview


Instance Method Summary collapse

Constructor Details

#initialize(help_text) ⇒ DefaultOptionParser

Returns a new instance of DefaultOptionParser.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gitomator/util/script_util.rb', line 18

def initialize(help_text)
  super()
  banner "#{help_text}\nOptions:"
  version "Gitomator #{Gitomator::VERSION} (c) 2016 Joey Freund"

  context_description = "YAML configuration for various service providers (e.g. GitHub hosting, or Travis CI)."
  unless ENV[DEFAULT_CONTEXT_ENV_VAR_NAME]
    context_description += "\nYou can override the default configuration file by setting the #{DEFAULT_CONTEXT_ENV_VAR_NAME} environment variable."
  end

  opt :context,
        context_description ,
        :type => :string,
        :default => ScriptUtil::default_context_file
end

Instance Method Details

#parse(args) ⇒ Object



35
36
37
38
39
# File 'lib/gitomator/util/script_util.rb', line 35

def parse(args)
  return { :context => ScriptUtil::default_context_file }.merge(
    Trollop::with_standard_exception_handling(self) { super(args)  }
  )
end