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.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pls/configurator.rb', line 25 def initialize ARGV << '-h' if ARGV.empty? = {} 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| [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.
12 13 14 |
# File 'lib/pls/configurator.rb', line 12 def files @files end |
Instance Method Details
#add(opt) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/pls/configurator.rb', line 18 def add(opt) opt.on('-v', '--version', 'Show version.') do puts "#{File.basename($PROGRAM_NAME)} #{VERSION} #{DATE}" exit end end |
#pac ⇒ Object
36 37 38 |
# File 'lib/pls/configurator.rb', line 36 def pac [:pac] end |
#url ⇒ Object
40 41 42 |
# File 'lib/pls/configurator.rb', line 40 def url 'https://registry.npmjs.org' end |