Class: UbuntuUpdate::OptionsParser
- Inherits:
-
Object
- Object
- UbuntuUpdate::OptionsParser
- Defined in:
- lib/ubuntu_update/options_parser.rb
Instance Method Summary collapse
- #get_engine ⇒ Object
- #get_options ⇒ Object
- #get_summary ⇒ Object
-
#initialize ⇒ OptionsParser
constructor
A new instance of OptionsParser.
- #parse(arguments) ⇒ Object
Constructor Details
#initialize ⇒ OptionsParser
Returns a new instance of OptionsParser.
6 7 8 |
# File 'lib/ubuntu_update/options_parser.rb', line 6 def initialize end |
Instance Method Details
#get_engine ⇒ Object
49 50 51 |
# File 'lib/ubuntu_update/options_parser.rb', line 49 def get_engine @option_parser end |
#get_options ⇒ Object
53 54 55 |
# File 'lib/ubuntu_update/options_parser.rb', line 53 def @options end |
#get_summary ⇒ Object
45 46 47 |
# File 'lib/ubuntu_update/options_parser.rb', line 45 def get_summary @summary end |
#parse(arguments) ⇒ 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 36 37 38 39 40 41 42 43 |
# File 'lib/ubuntu_update/options_parser.rb', line 10 def parse arguments @options = {} @option_parser = OptionParser.new do |opts| opts. = "Usage: ubuntu_upgrade.rb [options]" opts.on("-v", "--verbose", "Run verbosely") do |v| @options[:verbose] = v end opts.on("-p", "--update", "Run apt-get update") do |p| @options[:update] = p end opts.on("-g", "--upgrade", "Run apt-get update") do |g| @options[:upgrade] = g end opts.on("-y", "--yes", "Silent confirmation") do |y| @options[:yes] = y end opts.on("-h", "--help", "Show usage summary") do |h| @options[:help] = h @summary = opts.help end end @option_parser.parse! arguments @options end |