Class: Flynn::CLI::Tools::OptionParser

Inherits:
OptionParser
  • Object
show all
Defined in:
lib/flynn/cli/tools/option_parser.rb

Constant Summary collapse

@@log_levels =
[Logger::INFO, Logger::DEBUG]

Instance Method Summary collapse

Instance Method Details

#add_general_options!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/flynn/cli/tools/option_parser.rb', line 16

def add_general_options!
	on "--dry-run", "Prevents this command from making changes" do |v|
		Flynn::CLI::Tools.options[:dry_run] = v
	end
	on "--verbose", "Sets log level to INFO" do
		Flynn::CLI::Tools.logger.level = Logger::INFO
	end
	on "--debug", "Sets log level to DEBUG" do
		Flynn::CLI::Tools.logger.level = Logger::DEBUG
	end
	if File.basename($0).start_with? "flynn-"
		on "-c CLUSTER", "--cluster CLUSTER", String, "Set the flynn cluster to use" do |v|
			Flynn::CLI::Tools.flynn_cluster = v
		end
	end
	on "-q", "--quiet", "Disables logging" do |v|
		Flynn::CLI::Tools.options[:quiet] = v
	end
	on "-h", "--help", "Prints this help" do
		puts self
		exit
	end
end

#parse!Object



8
9
10
11
12
13
14
15
# File 'lib/flynn/cli/tools/option_parser.rb', line 8

def parse!
	begin
		super
	rescue ::OptionParser::InvalidOption, ::OptionParser::MissingArgument
		puts self
		exit 1
	end
end