corl 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitmodules +4 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +123 -0
- data/LICENSE.txt +674 -0
- data/README.rdoc +27 -0
- data/Rakefile +78 -0
- data/VERSION +1 -0
- data/bin/corl +55 -0
- data/corl.gemspec +228 -0
- data/lib/corl/action/add.rb +69 -0
- data/lib/corl/action/bootstrap.rb +83 -0
- data/lib/corl/action/clone.rb +40 -0
- data/lib/corl/action/create.rb +55 -0
- data/lib/corl/action/exec.rb +41 -0
- data/lib/corl/action/extract.rb +49 -0
- data/lib/corl/action/image.rb +30 -0
- data/lib/corl/action/images.rb +55 -0
- data/lib/corl/action/lookup.rb +35 -0
- data/lib/corl/action/machines.rb +51 -0
- data/lib/corl/action/provision.rb +37 -0
- data/lib/corl/action/remove.rb +51 -0
- data/lib/corl/action/save.rb +53 -0
- data/lib/corl/action/seed.rb +115 -0
- data/lib/corl/action/spawn.rb +75 -0
- data/lib/corl/action/start.rb +37 -0
- data/lib/corl/action/stop.rb +30 -0
- data/lib/corl/action/update.rb +37 -0
- data/lib/corl/command/shell.rb +164 -0
- data/lib/corl/configuration/file.rb +386 -0
- data/lib/corl/event/puppet.rb +90 -0
- data/lib/corl/event/regex.rb +52 -0
- data/lib/corl/extension/puppetloader.rb +24 -0
- data/lib/corl/machine/fog.rb +310 -0
- data/lib/corl/machine/physical.rb +161 -0
- data/lib/corl/network/default.rb +26 -0
- data/lib/corl/node/aws.rb +90 -0
- data/lib/corl/node/fog.rb +198 -0
- data/lib/corl/node/google.rb +115 -0
- data/lib/corl/node/local.rb +26 -0
- data/lib/corl/node/rackspace.rb +89 -0
- data/lib/corl/project/git.rb +465 -0
- data/lib/corl/project/github.rb +108 -0
- data/lib/corl/provisioner/puppetnode/resource.rb +245 -0
- data/lib/corl/provisioner/puppetnode/resource_group.rb +205 -0
- data/lib/corl/provisioner/puppetnode.rb +407 -0
- data/lib/corl/template/environment.rb +73 -0
- data/lib/corl/template/json.rb +16 -0
- data/lib/corl/template/wrapper.rb +16 -0
- data/lib/corl/template/yaml.rb +16 -0
- data/lib/corl/translator/json.rb +27 -0
- data/lib/corl/translator/yaml.rb +27 -0
- data/lib/corl.rb +173 -0
- data/lib/corl_core/codes.rb +107 -0
- data/lib/corl_core/config/collection.rb +57 -0
- data/lib/corl_core/config/options.rb +70 -0
- data/lib/corl_core/config.rb +337 -0
- data/lib/corl_core/core.rb +59 -0
- data/lib/corl_core/corl.rb +254 -0
- data/lib/corl_core/errors.rb +84 -0
- data/lib/corl_core/facade.rb +126 -0
- data/lib/corl_core/gems.rb +72 -0
- data/lib/corl_core/manager.rb +425 -0
- data/lib/corl_core/mixin/action/commit.rb +58 -0
- data/lib/corl_core/mixin/action/keypair.rb +105 -0
- data/lib/corl_core/mixin/action/node.rb +129 -0
- data/lib/corl_core/mixin/action/project.rb +53 -0
- data/lib/corl_core/mixin/action/push.rb +52 -0
- data/lib/corl_core/mixin/config/collection.rb +53 -0
- data/lib/corl_core/mixin/config/ops.rb +53 -0
- data/lib/corl_core/mixin/config/options.rb +39 -0
- data/lib/corl_core/mixin/lookup.rb +196 -0
- data/lib/corl_core/mixin/macro/object_interface.rb +361 -0
- data/lib/corl_core/mixin/macro/plugin_interface.rb +380 -0
- data/lib/corl_core/mixin/settings.rb +46 -0
- data/lib/corl_core/mixin/sub_config.rb +148 -0
- data/lib/corl_core/mod/hash.rb +29 -0
- data/lib/corl_core/mod/hiera_backend.rb +63 -0
- data/lib/corl_core/plugin/action.rb +381 -0
- data/lib/corl_core/plugin/base.rb +374 -0
- data/lib/corl_core/plugin/command.rb +98 -0
- data/lib/corl_core/plugin/configuration.rb +177 -0
- data/lib/corl_core/plugin/event.rb +53 -0
- data/lib/corl_core/plugin/extension.rb +12 -0
- data/lib/corl_core/plugin/machine.rb +266 -0
- data/lib/corl_core/plugin/network.rb +359 -0
- data/lib/corl_core/plugin/node.rb +904 -0
- data/lib/corl_core/plugin/project.rb +927 -0
- data/lib/corl_core/plugin/provisioner.rb +51 -0
- data/lib/corl_core/plugin/template.rb +80 -0
- data/lib/corl_core/plugin/translator.rb +38 -0
- data/lib/corl_core/util/cli.rb +352 -0
- data/lib/corl_core/util/data.rb +404 -0
- data/lib/corl_core/util/disk.rb +114 -0
- data/lib/corl_core/util/git.rb +47 -0
- data/lib/corl_core/util/interface.rb +319 -0
- data/lib/corl_core/util/liquid.rb +17 -0
- data/lib/corl_core/util/package.rb +93 -0
- data/lib/corl_core/util/shell.rb +239 -0
- data/lib/corl_core/util/ssh.rb +286 -0
- data/lib/facter/corl_config_ready.rb +13 -0
- data/lib/facter/corl_exists.rb +15 -0
- data/lib/facter/corl_network.rb +17 -0
- data/lib/hiera/corl_logger.rb +18 -0
- data/lib/puppet/indirector/corl.rb +27 -0
- data/lib/puppet/indirector/data_binding/corl.rb +6 -0
- data/lib/puppet/parser/functions/config_initialized.rb +26 -0
- data/lib/puppet/parser/functions/corl_include.rb +44 -0
- data/lib/puppet/parser/functions/corl_resources.rb +58 -0
- data/lib/puppet/parser/functions/deep_merge.rb +21 -0
- data/lib/puppet/parser/functions/ensure.rb +29 -0
- data/lib/puppet/parser/functions/file_exists.rb +19 -0
- data/lib/puppet/parser/functions/global_array.rb +35 -0
- data/lib/puppet/parser/functions/global_hash.rb +35 -0
- data/lib/puppet/parser/functions/global_options.rb +23 -0
- data/lib/puppet/parser/functions/global_param.rb +43 -0
- data/lib/puppet/parser/functions/interpolate.rb +26 -0
- data/lib/puppet/parser/functions/is_false.rb +21 -0
- data/lib/puppet/parser/functions/is_true.rb +21 -0
- data/lib/puppet/parser/functions/module_array.rb +38 -0
- data/lib/puppet/parser/functions/module_hash.rb +38 -0
- data/lib/puppet/parser/functions/module_options.rb +23 -0
- data/lib/puppet/parser/functions/module_param.rb +48 -0
- data/lib/puppet/parser/functions/name.rb +21 -0
- data/lib/puppet/parser/functions/render.rb +33 -0
- data/lib/puppet/parser/functions/value.rb +21 -0
- data/locales/en.yml +232 -0
- data/spec/corl_core/interface_spec.rb +489 -0
- data/spec/corl_mock_input.rb +29 -0
- data/spec/corl_test_kernel.rb +22 -0
- data/spec/spec_helper.rb +15 -0
- metadata +406 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
module CORL
|
3
|
+
module Plugin
|
4
|
+
class Provisioner < Base
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------------
|
7
|
+
# Provisioner plugin interface
|
8
|
+
|
9
|
+
def normalize
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
#---
|
14
|
+
|
15
|
+
def initialized?(options = {})
|
16
|
+
end
|
17
|
+
|
18
|
+
#---
|
19
|
+
|
20
|
+
def register
|
21
|
+
end
|
22
|
+
|
23
|
+
#-----------------------------------------------------------------------------
|
24
|
+
# Property accessor / modifiers
|
25
|
+
|
26
|
+
def hiera_config
|
27
|
+
end
|
28
|
+
|
29
|
+
#-----------------------------------------------------------------------------
|
30
|
+
# Provisioner operations
|
31
|
+
|
32
|
+
def lookup(property, default = nil, options = {})
|
33
|
+
end
|
34
|
+
|
35
|
+
#--
|
36
|
+
|
37
|
+
def import(files)
|
38
|
+
end
|
39
|
+
|
40
|
+
#---
|
41
|
+
|
42
|
+
def include(resource_name, properties, options = {})
|
43
|
+
end
|
44
|
+
|
45
|
+
#---
|
46
|
+
|
47
|
+
def provision(options = {})
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
|
2
|
+
module CORL
|
3
|
+
module Plugin
|
4
|
+
class Template < Base
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------------
|
7
|
+
# Template plugin interface
|
8
|
+
|
9
|
+
|
10
|
+
#-----------------------------------------------------------------------------
|
11
|
+
# Property accessor / modifiers
|
12
|
+
|
13
|
+
#-----------------------------------------------------------------------------
|
14
|
+
# Operations
|
15
|
+
|
16
|
+
def process(value)
|
17
|
+
case value
|
18
|
+
when String, Symbol
|
19
|
+
return nil if Util::Data.undef?(value)
|
20
|
+
return 'false' if value == false
|
21
|
+
return 'true' if value == true
|
22
|
+
return value.to_s if value.is_a?(Symbol)
|
23
|
+
|
24
|
+
when Hash
|
25
|
+
results = {}
|
26
|
+
value.each do |key, item|
|
27
|
+
result = process(item)
|
28
|
+
unless result.nil?
|
29
|
+
results[key] = result
|
30
|
+
end
|
31
|
+
value = results
|
32
|
+
end
|
33
|
+
|
34
|
+
when Array
|
35
|
+
results = []
|
36
|
+
value.each_with_index do |item, index|
|
37
|
+
result = process(item)
|
38
|
+
unless result.nil?
|
39
|
+
results << result
|
40
|
+
end
|
41
|
+
end
|
42
|
+
value = results
|
43
|
+
end
|
44
|
+
return value
|
45
|
+
end
|
46
|
+
|
47
|
+
#---
|
48
|
+
|
49
|
+
def render(data)
|
50
|
+
normalize = get(:normalize_template, true)
|
51
|
+
interpolate = get(:interpolate_template, true)
|
52
|
+
|
53
|
+
logger.debug("Rendering data: normalize: #{normalize.inspect}; interpolate: #{interpolate.inspect}: #{data.inspect}")
|
54
|
+
|
55
|
+
if normalize
|
56
|
+
data = Config.normalize(data, nil, config)
|
57
|
+
logger.debug("Pre-rendering data normalization: #{data.inspect}")
|
58
|
+
end
|
59
|
+
|
60
|
+
if normalize && interpolate
|
61
|
+
data = Util::Data.interpolate(data, data, export)
|
62
|
+
logger.debug("Pre-rendering data interpolation: #{data.inspect}")
|
63
|
+
end
|
64
|
+
return render_processed(process(data))
|
65
|
+
end
|
66
|
+
|
67
|
+
#---
|
68
|
+
|
69
|
+
def render_processed(data)
|
70
|
+
logger.debug("Rendering #{plugin_provider} data: #{data.inspect}")
|
71
|
+
|
72
|
+
output = ''
|
73
|
+
output = yield(output) if block_given?
|
74
|
+
|
75
|
+
logger.debug("Completed rendering of #{plugin_provider} data: #{output}")
|
76
|
+
return output
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
module CORL
|
3
|
+
module Plugin
|
4
|
+
class Translator < Base
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------------
|
7
|
+
# Translator plugin interface
|
8
|
+
|
9
|
+
#-----------------------------------------------------------------------------
|
10
|
+
# Property accessor / modifiers
|
11
|
+
|
12
|
+
#-----------------------------------------------------------------------------
|
13
|
+
# Operations
|
14
|
+
|
15
|
+
def parse(raw)
|
16
|
+
logger.debug("Parsing raw data: #{raw}")
|
17
|
+
|
18
|
+
properties = {}
|
19
|
+
properties = yield(properties) if block_given?
|
20
|
+
|
21
|
+
logger.debug("Completed parsing data: #{properties.inspect}")
|
22
|
+
return properties
|
23
|
+
end
|
24
|
+
|
25
|
+
#---
|
26
|
+
|
27
|
+
def generate(properties)
|
28
|
+
logger.debug("Generating output data: #{properties.inspect}")
|
29
|
+
|
30
|
+
output = ''
|
31
|
+
output = yield(output) if block_given?
|
32
|
+
|
33
|
+
logger.debug("Completed generating data: #{output}")
|
34
|
+
return output
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,352 @@
|
|
1
|
+
module CORL
|
2
|
+
module Util
|
3
|
+
module CLI
|
4
|
+
|
5
|
+
#-------------------------------------------------------------------------
|
6
|
+
# Utilities
|
7
|
+
|
8
|
+
def self.message(name, default = nil)
|
9
|
+
if default.nil?
|
10
|
+
default = :none
|
11
|
+
end
|
12
|
+
return I18n.t(name.to_s, :default_value => default.to_s)
|
13
|
+
end
|
14
|
+
|
15
|
+
#---
|
16
|
+
|
17
|
+
def self.encode(data)
|
18
|
+
Base64.encode64(Util::Data.to_json(data, false))
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.decode(encoded_string)
|
22
|
+
Util::Data.symbol_map(Util::Data.parse_json(Base64.decode64(encoded_string)))
|
23
|
+
end
|
24
|
+
|
25
|
+
#-------------------------------------------------------------------------
|
26
|
+
# Parser
|
27
|
+
|
28
|
+
class Parser
|
29
|
+
|
30
|
+
attr_accessor :parser
|
31
|
+
attr_accessor :options
|
32
|
+
attr_accessor :arguments
|
33
|
+
attr_accessor :processed
|
34
|
+
|
35
|
+
#---
|
36
|
+
|
37
|
+
def initialize(args, banner = '', help = '')
|
38
|
+
|
39
|
+
@parser = OptionParser.new
|
40
|
+
|
41
|
+
self.options = {}
|
42
|
+
self.arguments = {}
|
43
|
+
self.processed = false
|
44
|
+
|
45
|
+
@arg_settings = []
|
46
|
+
|
47
|
+
self.banner = banner
|
48
|
+
self.help = help
|
49
|
+
|
50
|
+
yield(self) if block_given?
|
51
|
+
|
52
|
+
parse_command(args)
|
53
|
+
end
|
54
|
+
|
55
|
+
#---
|
56
|
+
|
57
|
+
def self.split(args, banner, separator = '')
|
58
|
+
main_args = nil
|
59
|
+
sub_command = nil
|
60
|
+
sub_args = []
|
61
|
+
|
62
|
+
args.each_index do |index|
|
63
|
+
if !args[index].start_with?('-')
|
64
|
+
main_args = args[0, index]
|
65
|
+
sub_command = args[index]
|
66
|
+
sub_args = args[index + 1, args.length - index + 1]
|
67
|
+
break
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
main_args = args.dup if main_args.nil?
|
72
|
+
results = [ Parser.new(main_args, banner, separator) ]
|
73
|
+
|
74
|
+
if sub_command
|
75
|
+
results << [ sub_command, sub_args ]
|
76
|
+
end
|
77
|
+
|
78
|
+
return results.flatten
|
79
|
+
end
|
80
|
+
|
81
|
+
#---
|
82
|
+
|
83
|
+
def banner=banner
|
84
|
+
parser.banner = banner
|
85
|
+
end
|
86
|
+
|
87
|
+
#---
|
88
|
+
|
89
|
+
def help
|
90
|
+
return parser.help
|
91
|
+
end
|
92
|
+
|
93
|
+
def help=help
|
94
|
+
if help.is_a?(Array)
|
95
|
+
help.each do |line|
|
96
|
+
parser.separator line
|
97
|
+
end
|
98
|
+
else
|
99
|
+
parser.separator help
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
#---
|
104
|
+
|
105
|
+
def parse_command(args)
|
106
|
+
args = args.dup
|
107
|
+
error = false
|
108
|
+
|
109
|
+
self.processed = false
|
110
|
+
|
111
|
+
option_str(:log_level, nil,
|
112
|
+
'--log_level STR',
|
113
|
+
'corl.core.util.cli.options.log_level'
|
114
|
+
)
|
115
|
+
option_str(:encoded_params, false,
|
116
|
+
'--encoded STR',
|
117
|
+
'corl.core.util.cli.options.encoded'
|
118
|
+
)
|
119
|
+
parser.on_tail('-h', '--help', CLI.message('corl.core.util.cli.options.help')) do
|
120
|
+
options[:help] = true
|
121
|
+
return
|
122
|
+
end
|
123
|
+
|
124
|
+
parser.parse!(args)
|
125
|
+
|
126
|
+
CORL.log_level = options[:log_level] if options[:log_level]
|
127
|
+
parse_encoded
|
128
|
+
|
129
|
+
remaining_args = args.dup
|
130
|
+
arg_messages = []
|
131
|
+
|
132
|
+
if arguments.empty?
|
133
|
+
@arg_settings.each_with_index do |settings, index|
|
134
|
+
if index >= args.length
|
135
|
+
value = nil
|
136
|
+
else
|
137
|
+
value = Util::Data.value(args[index])
|
138
|
+
end
|
139
|
+
|
140
|
+
if !value.nil? && settings.has_key?(:allowed)
|
141
|
+
allowed = settings[:allowed]
|
142
|
+
case allowed
|
143
|
+
when Class
|
144
|
+
if (allowed == Array)
|
145
|
+
value = remaining_args
|
146
|
+
remaining_args = []
|
147
|
+
end
|
148
|
+
unless value.is_a?(allowed)
|
149
|
+
arg_messages << CLI.message(settings[:message])
|
150
|
+
error = true
|
151
|
+
end
|
152
|
+
when Array
|
153
|
+
unless allowed.include(value)
|
154
|
+
arg_messages << CLI.message(settings[:message])
|
155
|
+
error = true
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
if value.nil?
|
161
|
+
if settings.has_key?(:default)
|
162
|
+
value = settings[:default]
|
163
|
+
else
|
164
|
+
error = true
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
if !value.nil? && settings.has_key?(:block)
|
169
|
+
value = settings[:block].call(value)
|
170
|
+
error = true if value.nil?
|
171
|
+
end
|
172
|
+
|
173
|
+
break if error
|
174
|
+
|
175
|
+
remaining_args.shift unless remaining_args.empty?
|
176
|
+
self.arguments[settings[:name]] = value
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
if error
|
181
|
+
if ! arg_messages.empty?
|
182
|
+
parser.warn(CLI.message('corl.core.util.cli.parse.error') + "\n\n" + arg_messages.join("\n") + "\n\n" + parser.help)
|
183
|
+
else
|
184
|
+
parser.warn(CLI.message('corl.core.util.cli.parse.error') + "\n\n" + parser.help)
|
185
|
+
end
|
186
|
+
else
|
187
|
+
self.processed = true
|
188
|
+
end
|
189
|
+
|
190
|
+
rescue OptionParser::InvalidOption => e
|
191
|
+
parser.warn(e.message + "\n\n" + parser.help)
|
192
|
+
end
|
193
|
+
|
194
|
+
#---
|
195
|
+
|
196
|
+
def parse_encoded
|
197
|
+
if options[:encoded_params]
|
198
|
+
encoded_properties = CLI.decode(options[:encoded_params])
|
199
|
+
|
200
|
+
@arg_settings.each do |settings|
|
201
|
+
if encoded_properties.has_key?(settings[:name].to_sym)
|
202
|
+
self.arguments[settings[:name]] = encoded_properties.delete(settings[:name].to_sym)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
encoded_properties.each do |name, value|
|
207
|
+
self.options[name] = value unless options.has_key?(name)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
options.delete(:encoded_params)
|
211
|
+
end
|
212
|
+
|
213
|
+
#---
|
214
|
+
|
215
|
+
def option(name, default, option_str, allowed_values, message_id, config = {})
|
216
|
+
config = Config.ensure(config)
|
217
|
+
name = name.to_sym
|
218
|
+
options[name] = config.get(name, default)
|
219
|
+
|
220
|
+
message_name = name.to_s + '_message'
|
221
|
+
message = CLI.message(message_id, options[name])
|
222
|
+
|
223
|
+
option_str = Util::Data.array(option_str)
|
224
|
+
|
225
|
+
if allowed_values
|
226
|
+
parser.on(*option_str, allowed_values, config.get(message_name.to_sym, message)) do |value|
|
227
|
+
value = yield(value) if block_given?
|
228
|
+
options[name] = value unless value.nil?
|
229
|
+
end
|
230
|
+
else
|
231
|
+
parser.on(*option_str, config.get(message_name.to_sym, message)) do |value|
|
232
|
+
value = yield(value) if block_given?
|
233
|
+
options[name] = value unless value.nil?
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
#---
|
239
|
+
|
240
|
+
def arg(name, default, allowed_values, message_id, config = {}, &block)
|
241
|
+
config = Config.ensure(config)
|
242
|
+
name = name.to_sym
|
243
|
+
|
244
|
+
message_name = name.to_s + '_message'
|
245
|
+
message = CLI.message(message_id, arguments[name])
|
246
|
+
|
247
|
+
settings = {
|
248
|
+
:name => name,
|
249
|
+
:default => config.get(name, default),
|
250
|
+
:message => config.get(message_name.to_sym, message)
|
251
|
+
}
|
252
|
+
settings[:allowed] = allowed_values if allowed_values
|
253
|
+
settings[:block] = block if block
|
254
|
+
|
255
|
+
settings.delete(:default) if settings[:default].nil?
|
256
|
+
|
257
|
+
@arg_settings << settings
|
258
|
+
end
|
259
|
+
|
260
|
+
#---
|
261
|
+
|
262
|
+
def option_bool(name, default, option_str, message_id, config = {})
|
263
|
+
option(name, default, option_str, nil, message_id, config) do |value|
|
264
|
+
value = Util::Data.value(value)
|
265
|
+
if value == true || value == false
|
266
|
+
block_given? ? yield(value) : value
|
267
|
+
else
|
268
|
+
nil
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
#---
|
274
|
+
|
275
|
+
def arg_bool(name, default, message_id, config = {})
|
276
|
+
arg(name, default, nil, message_id, config) do |value|
|
277
|
+
value = Util::Data.value(value)
|
278
|
+
if value == true || value == false
|
279
|
+
block_given? ? yield(value) : value
|
280
|
+
else
|
281
|
+
nil
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
#---
|
287
|
+
|
288
|
+
def option_int(name, default, option_str, message_id, config = {})
|
289
|
+
option(name, default, option_str, Integer, message_id, config) do |value|
|
290
|
+
block_given? ? yield(value) : value
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
#---
|
295
|
+
|
296
|
+
def arg_int(name, default, message_id, config = {})
|
297
|
+
arg(name, default, Integer, message_id, config) do |value|
|
298
|
+
block_given? ? yield(value) : value
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
#---
|
303
|
+
|
304
|
+
def option_float(name, default, option_str, message_id, config = {})
|
305
|
+
option(name, default, option_str, Float, message_id, config) do |value|
|
306
|
+
block_given? ? yield(value) : value
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
#---
|
311
|
+
|
312
|
+
def arg_float(name, default, message_id, config = {})
|
313
|
+
arg(name, default, Float, message_id, config) do |value|
|
314
|
+
block_given? ? yield(value) : value
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
#---
|
319
|
+
|
320
|
+
def option_str(name, default, option_str, message_id, config = {})
|
321
|
+
option(name, default, option_str, nil, message_id, config) do |value|
|
322
|
+
block_given? ? yield(value) : value
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
#---
|
327
|
+
|
328
|
+
def arg_str(name, default, message_id, config = {})
|
329
|
+
arg(name, default, nil, message_id, config) do |value|
|
330
|
+
block_given? ? yield(value) : value
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
#---
|
335
|
+
|
336
|
+
def option_array(name, default, option_str, message_id, config = {})
|
337
|
+
option(name, default, option_str, Array, message_id, config) do |value|
|
338
|
+
block_given? ? yield(value) : value
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
#---
|
343
|
+
|
344
|
+
def arg_array(name, default, message_id, config = {})
|
345
|
+
arg(name, default, Array, message_id, config) do |value|
|
346
|
+
block_given? ? yield(value) : value
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|