Class: Ardecy::Options
- Inherits:
-
Object
- Object
- Ardecy::Options
- Defined in:
- lib/ardecy/options.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #parse(args) ⇒ Object
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
9 10 11 12 |
# File 'lib/ardecy/options.rb', line 9 def initialize(args) @options = {} parse(args) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/ardecy/options.rb', line 7 def @options end |
Instance Method Details
#parse(args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ardecy/options.rb', line 14 def parse(args) OptionParser.new do |opts| opts.on('--audit', 'Perform local security scan.') do @options[:audit] = true end opts.on('--fix', 'Fix problems.') do @options[:fix] = true end opts.on('--path-bootctl PATH', String, 'Path for bootctl, esp should be mounted') do |f| raise "No file #{f}" unless File.exists? f @options[:bootctl] = f end opts.on('--path-syslinux PATH', String, 'Path for syslinux if not /boot/syslinux/syslinux.cfg') do |f| raise "No file #{f}" unless File.exists? f @options[:syslinux] = f end opts.on('-h', '--help', 'Show this message.') do puts opts exit end begin args.push('-h') if args.empty? opts.parse!(args) rescue OptionParser::ParseError => e warn e., "\n", opts exit 1 end end end |