Class: UbuntuUpdate::OptionsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ubuntu_update/options_parser.rb

Instance Method Summary collapse

Constructor Details

#initializeOptionsParser

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_engineObject



49
50
51
# File 'lib/ubuntu_update/options_parser.rb', line 49

def get_engine
	@option_parser
end

#get_optionsObject



53
54
55
# File 'lib/ubuntu_update/options_parser.rb', line 53

def get_options
	@options
end

#get_summaryObject



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.banner = "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