Class: GeneratePuppetfile::OptParser
- Inherits:
-
Object
- Object
- GeneratePuppetfile::OptParser
- Defined in:
- lib/generate_puppetfile/optparser.rb
Overview
Internal: Parse the options provided to generate-puppetfile
Class Method Summary collapse
-
.parse(args) ⇒ Object
Internal: Initialize the OptionParser.
Class Method Details
.parse(args) ⇒ Object
Internal: Initialize the OptionParser
Returns an OptionParser object.
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 |
# File 'lib/generate_puppetfile/optparser.rb', line 10 def self.parse(args) = {} opts = OptionParser.new do |opts| opts. = "generate-puppetfile [OPTIONS] [<MODULE> ... <MODULE>]" opts.on('-p', '--puppetfile FILE', 'Name of existing Puppetfile to verify and update') do |file| unless File.readable?(file) puts "\nPuppetfile '#{file}' cannot be read. Are you sure you passed in the correct filename?\n\n" exit 1 end [:puppetfile] = file end opts.on('-d', '--debug', 'Enable debug logging') do [:debug] = true end opts.on_tail('-v', '--version', 'Show version') do puts "generate-puppetfile v#{GeneratePuppetfile::VERSION}" end end opts.parse!(args) end |