Class: Pls::Configurator
- Inherits:
-
Object
- Object
- Pls::Configurator
- Defined in:
- lib/pls/configurator.rb
Overview
Handles input parameters.
Constant Summary collapse
- DIC =
[ ['-p', '--pac package', 'Package name.', String, :pac] ].freeze
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #add(opt) ⇒ Object
-
#initialize ⇒ Configurator
constructor
A new instance of Configurator.
- #pac ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize ⇒ Configurator
Returns a new instance of Configurator.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pls/configurator.rb', line 24 def initialize ARGV << '-h' if ARGV.empty? @options = {} OptionParser.new do |o| o. = "Usage: #{File.basename($PROGRAM_NAME)} [options]." DIC.each { |f, p, d, t, k| o.on(f, p, t, d) { |i| @options[k] = i } } add(o) end.parse! raise 'Please specify a package name with -p flag.' if pac.nil? end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
11 12 13 |
# File 'lib/pls/configurator.rb', line 11 def files @files end |
Instance Method Details
#add(opt) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/pls/configurator.rb', line 17 def add(opt) opt.on('-v', '--version', 'Show version.') do puts "#{File.basename($PROGRAM_NAME)} #{VERSION} #{DATE}" exit end end |
#pac ⇒ Object
35 36 37 |
# File 'lib/pls/configurator.rb', line 35 def pac @options[:pac] end |
#url ⇒ Object
39 40 41 |
# File 'lib/pls/configurator.rb', line 39 def url 'https://registry.npmjs.org' end |