Class: Bunup::Options
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Bunup::Options
- Defined in:
- lib/bunup/options.rb
Overview
Handle command-line switches
Class Method Summary collapse
Class Method Details
.parse!(args) ⇒ Object
9 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/bunup/options.rb', line 9 def self.parse!(args) = new opt_parser = ::OptionParser.new do |opts| opts. = 'Usage: bunup [options] | <gem_name> [<gem_name>...]' opts.program_name = 'bunup' opts.version = ::Bunup::VERSION opts.on('--all', 'Update all outdated gems (default)') do .all = true end assume_yes_msg = 'Answer "yes" to all major or git version update ' \ 'prompts, or all, and run non-interactively. Defaults to all.' opts.on( '-y', '--yes', '--assume-yes [major, git]', Array, assume_yes_msg ) do |list| if list.nil? [:assume_yes_for_major_version_update] = true [:assume_yes_for_git_update] = true else list.each do |version_type| case version_type.strip when 'major' [:assume_yes_for_major_version_update] = true when 'git' then [:assume_yes_for_git_update] = true end end end end opts.on('--only-explicit') do [:only_explicit] = true end opts.on('-h', '--help', 'Prints this help') do puts opts exit end end opt_parser.parse!(args) .all = true if args.empty? rescue OptionParser::InvalidOption => e puts e puts opt_parser abort end |