Class: Front::CLI::Configuration
- Inherits:
-
Object
- Object
- Front::CLI::Configuration
show all
- Includes:
- Loader
- Defined in:
- lib/front/cli/configuration.rb
Constant Summary
Constants included
from Loader
Loader::LIB_DIR, Loader::ROOT_DIR
Instance Method Summary
collapse
Instance Method Details
#get_parser(args, options) ⇒ Object
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
|
# File 'lib/front/cli/configuration.rb', line 18
def get_parser(args, options)
OptionParser.new do |opts|
options.opts = opts
opts.banner = 'Usage: front [options] [action]'
opts.separator ''
opts.separator 'Actions'
opts.separator ' create : create a new pool'
opts.separator ' destroy : destroy pool'
opts.separator ' next : switch to next instance in pool'
opts.separator ' ssh : ssh to current instance => vagrant ssh'
opts.separator ' ssh_config : print ssh config for current instance'
opts.separator ' inventory : print inventory file (for ansible)'
opts.separator ''
opts.separator 'Options'
opts.separator ''
opts.on('-s', '--size <size>', Integer, 'Size of instance pool') do |pool_size|
options.pool_size = pool_size
end
opts.on_tail('-V', '--version', 'Print Front version') do
options.action = :show_version
end
opts.on_tail('-h', '--help', 'Print Front help') do
options.action = :show_help
end
end
end
|
#load(args) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/front/cli/configuration.rb', line 9
def load(args)
options = OpenStruct.new
options.action = nil
options.error = nil
options.pool_size = 2
parse(args, options)
end
|
#parse(args, options) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/front/cli/configuration.rb', line 48
def parse(args, options)
parser = get_parser(args, options)
begin
parser.parse!(args)
if options.action.nil?
if args.length == 1
options.action = args[0]
else
raise OptionParser::InvalidOption.new(args)
end
end
rescue OptionParser::InvalidOption => err
options.error = err
options.action = :show_invalid_option
rescue OptionParser::MissingArgument => err
options.error = err
options.action = :show_missing_args
rescue OptionParser::ParseError => err
options.error = err
options.action = :show_parser_error
end
options
end
|