cli_helper 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cli_helper.gemspec +4 -4
- data/example/cli_stub.rb +89 -17
- data/lib/cli_helper.rb +75 -8
- data/tests/cli_helper_test.rb +97 -3
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daf61d8cbabeb65a4cca02b574eec433477be112
|
4
|
+
data.tar.gz: d7bda7e83f7f3c2f9bbabf66df68f0b398b4466f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42014bd7d2a2718ba08ab8dc01d0b87f45116903a85634c04b3a104761cd34e48ccec049b1f51bb18b9c55c83371fe1e78adbb34a1a9b9e33d46d017bb93898d
|
7
|
+
data.tar.gz: d7bbf67ba09b13516d3e02536eb1b20a9a7a40b484aca5c468386c8e03ededb478d98acf9d66f0b27f4e3be2e4d577691315359ee9a2d688466e879639d07aa4
|
data/cli_helper.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "cli_helper"
|
7
|
-
spec.version = '0.1.
|
7
|
+
spec.version = '0.1.8'
|
8
8
|
spec.authors = ["Dewayne VanHoozer"]
|
9
9
|
spec.email = ["dvanhoozer@gmail.com"]
|
10
10
|
|
@@ -31,10 +31,10 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency 'configatron'
|
32
32
|
spec.add_dependency 'nenv'
|
33
33
|
spec.add_dependency 'inifile'
|
34
|
-
spec.add_dependency 'slop', "~> 4.
|
34
|
+
spec.add_dependency 'slop', "~> 4.2"
|
35
35
|
|
36
|
-
spec.add_development_dependency "bundler"
|
37
|
-
spec.add_development_dependency "rake"
|
36
|
+
spec.add_development_dependency "bundler"
|
37
|
+
spec.add_development_dependency "rake"
|
38
38
|
spec.add_development_dependency 'kick_the_tires'
|
39
39
|
spec.add_development_dependency 'awesome_print'
|
40
40
|
spec.add_development_dependency 'debug_me'
|
data/example/cli_stub.rb
CHANGED
@@ -7,34 +7,40 @@
|
|
7
7
|
## By: Dewayne VanHoozer (dvanhoozer@gmail.com)
|
8
8
|
#
|
9
9
|
|
10
|
+
require 'debug_me'
|
11
|
+
include DebugMe
|
12
|
+
|
10
13
|
require 'awesome_print'
|
11
14
|
|
12
15
|
require '../lib/cli_helper'
|
13
16
|
include CliHelper
|
14
17
|
|
15
|
-
configatron.version = '0.0.
|
16
|
-
configatron.enable_config_files =
|
18
|
+
configatron.version = '0.0.3' # the version of this utility program
|
19
|
+
configatron.enable_config_files = false # default is false
|
17
20
|
configatron.disable_help = false # default is false set true to remove the option
|
18
21
|
configatron.disable_verbose = false # ditto
|
19
22
|
configatron.disable_debug = false # ditto
|
20
23
|
configatron.disable_version = false # ditto
|
21
|
-
configatron.suppress_errors =
|
24
|
+
configatron.suppress_errors = true # default is true; set to false to receive exceptions from Slop
|
22
25
|
|
23
26
|
|
24
27
|
# Sometimes you may have a few default config files that you
|
25
28
|
# want to apply before the command-line options. Do it like
|
26
|
-
#
|
29
|
+
# this:
|
30
|
+
|
31
|
+
=begin
|
27
32
|
%w[
|
28
33
|
../tests/config/sample.yml
|
29
34
|
../tests/config/sample.yml.erb
|
30
35
|
].each do |dcf|
|
31
36
|
cli_helper_process_config_file(dcf)
|
32
37
|
end
|
38
|
+
=end
|
33
39
|
|
34
40
|
# OR just pass a directory and all of the config files in the
|
35
41
|
# directory will be processed:
|
36
42
|
|
37
|
-
cli_helper_process_config_file('../tests/config')
|
43
|
+
# cli_helper_process_config_file('../tests/config')
|
38
44
|
|
39
45
|
|
40
46
|
# HELP is extra stuff shown with usage. It is optional. You
|
@@ -66,7 +72,7 @@ EOHELP
|
|
66
72
|
#
|
67
73
|
# -h, --help will automatically show a usage message on STDOUT and exit the program
|
68
74
|
# --version will print the program's version string to STDOUT and exit
|
69
|
-
#
|
75
|
+
# -v, --verbose will set the verbose boolean to true.
|
70
76
|
# -d, --debug will set the debug boolean to true.
|
71
77
|
# All boolean options have '?' and '!' methods generated, For example debug? and
|
72
78
|
# verbose? are automatically generated. Any program-specific booleans specified will
|
@@ -78,26 +84,55 @@ cli_helper("An example use of cli_helper") do |o|
|
|
78
84
|
# For a complete list of stuff see Slop on github.com
|
79
85
|
# https://github.com/leejarvis/slop
|
80
86
|
|
87
|
+
# boolean parameters will also generate the methods long-parameter? and long-parameter!
|
88
|
+
# for example this line:
|
89
|
+
o.bool '-b', '--bullstuff', default: false
|
90
|
+
|
91
|
+
# will auto generate the methods bullstuff? and bullstuff!
|
92
|
+
# where bullstuff? returns the value of configatron.bullstuff
|
93
|
+
# and bullstuff! sets the value of configatron.bullstuff to true
|
94
|
+
#
|
95
|
+
# NOTE: boolean options are special in that default: false is assumed
|
96
|
+
# when no default item is provided. This means that
|
97
|
+
# o.bool '-e', 'Example', default: false
|
98
|
+
# and o.bool '-e', 'Example'
|
99
|
+
# are treated identically. The value for the parameter will be false when the
|
100
|
+
# parameter is included on the command line.
|
101
|
+
#
|
102
|
+
# This is NOT the case for other parameter classes. For them, if no default is
|
103
|
+
# provided AND they are not present on the command line, THEN their value will be
|
104
|
+
# nil AND they will (by convention) be treated as a required parameter that has
|
105
|
+
# not been provided. This will result in a warning message being generated.
|
106
|
+
|
107
|
+
|
81
108
|
o.string '-s', '--string', 'example string parameter', default: 'IamDefault'
|
82
|
-
o.
|
109
|
+
o.string '-r', '--required', 'a required parameter' # I know its required because there is no default
|
110
|
+
o.bool '--xyzzy', 'a required boolean without a default', required: true
|
111
|
+
|
112
|
+
# NOTE: you can use many "flags" in defining an option. Each is valid on the command line.
|
113
|
+
# However, only the last flag can be used to retrieve the value via the configatron capability.
|
114
|
+
# To get the value entered by the user for this integer parameter you must use:
|
115
|
+
# configatron.i3 or configatron['i3'] or configatron[:i3]
|
83
116
|
|
84
|
-
|
85
|
-
#o.float '-f', '--float', 'example float parameter', default: (22.0 / 7.0)
|
117
|
+
o.int '-i', '--i2', '--i3', 'example integer parameter', default: 42
|
86
118
|
|
119
|
+
|
120
|
+
o.float '-f', '--float', 'example float parameter', default: (22.0 / 7.0)
|
87
121
|
o.array '-a', '--array', 'example array parameter', default: [:bob, :carol, :ted, :alice]
|
88
122
|
o.path '-p', '--path', 'example Pathname parameter', default: Pathname.new('default/path/to/file.txt')
|
89
|
-
o.paths '--paths', 'example Pathnames parameter', delimiter: ',',
|
90
|
-
'file2.txt'].map{|f| Pathname.new f}
|
123
|
+
o.paths '--paths', 'example Pathnames parameter', delimiter: ',',
|
124
|
+
default: ['default/path/to/file.txt', 'file2.txt'].map{|f| Pathname.new f}
|
91
125
|
|
92
|
-
# FIXME: Issue with Slop; default is not passed to the block. When no parameter is
|
93
|
-
# given, an exception is raised. Using the suppress_errors: true option silents
|
94
|
-
# the exception BUT still the default value is not passed to the block.
|
95
|
-
# This issue has been raised with the Slop author and a fix is in the works.
|
96
126
|
o.string '-n', '--name', 'print Hello <name>', default: 'World!', suppress_errors: true do |a_string|
|
97
127
|
a_string = 'world' if a_string.empty?
|
98
128
|
puts "Hello #{a_string}"
|
99
129
|
end
|
100
130
|
|
131
|
+
o.on '--quit', "print 'Take this option and do it!' and then exit" do
|
132
|
+
puts 'Take this option and do it!'
|
133
|
+
exit
|
134
|
+
end
|
135
|
+
|
101
136
|
end
|
102
137
|
|
103
138
|
# ARGV is not touched. However all command line parameters that are not consummed
|
@@ -125,8 +160,6 @@ if configatron.arguments.include?('warning')
|
|
125
160
|
end
|
126
161
|
|
127
162
|
=begin
|
128
|
-
|
129
|
-
rescue
|
130
163
|
configatron.errors and configatron.warnings are of type Array.
|
131
164
|
All warnings will be presented to the user. The user will
|
132
165
|
be asked wither the program should be aborted.
|
@@ -172,3 +205,42 @@ EOS
|
|
172
205
|
|
173
206
|
puts stub
|
174
207
|
|
208
|
+
# The values of command line parameters are available anywhere via configatron as
|
209
|
+
# either methods or hash keys. The name of the method/key is the name of the
|
210
|
+
# last "flag" defined for that option. For example the name option was defined
|
211
|
+
# with the flags "-n" and "--name" so you can access that parameter like this:
|
212
|
+
|
213
|
+
puts "\n\nHello #{configatron.name}"
|
214
|
+
|
215
|
+
# or like this:
|
216
|
+
|
217
|
+
puts "Hello #{configatron['name']}"
|
218
|
+
|
219
|
+
# or like this:
|
220
|
+
|
221
|
+
puts "Hello #{configatron[:name]}\n\n"
|
222
|
+
|
223
|
+
__END__
|
224
|
+
|
225
|
+
The same thing is true if only a single letter "-z" is used.
|
226
|
+
Access the value like this:
|
227
|
+
|
228
|
+
configatron.z
|
229
|
+
configatron['z']
|
230
|
+
configatron[:z]
|
231
|
+
|
232
|
+
Regardless of how many "flags" are defined for an option, it is only the
|
233
|
+
last one in the list that is used to access its value. In the "name" example
|
234
|
+
about you CANNOT access the value via configatron.n because "--name" was the
|
235
|
+
last flag defined for the option.
|
236
|
+
|
237
|
+
When the user enters a "flag" more than once on a command line only the value of
|
238
|
+
The last entry will be kept.
|
239
|
+
|
240
|
+
Run this program with the following parameters and see what happens:
|
241
|
+
|
242
|
+
-n Tom -n Dick -n Harry
|
243
|
+
|
244
|
+
you should get a warning that there were multiple entries on the command
|
245
|
+
line. The value that is used will be the last one - "Harry"
|
246
|
+
|
data/lib/cli_helper.rb
CHANGED
@@ -60,11 +60,11 @@ module CliHelper
|
|
60
60
|
disable_debug: false,
|
61
61
|
disable_verbose: false,
|
62
62
|
disable_version: false,
|
63
|
-
suppress_errors:
|
63
|
+
suppress_errors: true, # suppress the exceptions generated by Slop
|
64
64
|
ini_comment: '#',
|
65
65
|
ini_seperator: '=',
|
66
66
|
ini_encoding: 'UTF-8',
|
67
|
-
user_name: Nenv.user || Nenv.user_name || Nenv.logname || 'The Unknown
|
67
|
+
user_name: Nenv.user || Nenv.user_name || Nenv.logname || 'The Unknown User',
|
68
68
|
home_path: Pathname.new(Nenv.home),
|
69
69
|
cli: 'a place holder for the Slop object',
|
70
70
|
errors: [],
|
@@ -75,8 +75,8 @@ module CliHelper
|
|
75
75
|
|
76
76
|
configatron.required_by_filename = caller.last.split(':').first
|
77
77
|
configatron.me = Pathname.new(configatron.required_by_filename).realpath
|
78
|
-
configatron.my_dir =
|
79
|
-
configatron.my_name =
|
78
|
+
configatron.my_dir = configatron.me.parent
|
79
|
+
configatron.my_name = configatron.me.basename.to_s
|
80
80
|
|
81
81
|
|
82
82
|
# Return full pathname of program
|
@@ -84,32 +84,41 @@ module CliHelper
|
|
84
84
|
configatron.me
|
85
85
|
end
|
86
86
|
|
87
|
+
|
87
88
|
# Return full pathname of program
|
88
89
|
def my_dir
|
89
90
|
configatron.my_dir
|
90
91
|
end
|
91
92
|
alias :root :my_dir
|
92
93
|
|
94
|
+
|
93
95
|
# Returns the basename of the program as a string
|
94
96
|
def my_name
|
95
97
|
configatron.my_name
|
96
98
|
end
|
97
99
|
|
100
|
+
|
98
101
|
# Returns the version of the program as a string
|
99
102
|
def version
|
100
103
|
configatron.version
|
101
104
|
end
|
102
105
|
|
106
|
+
|
107
|
+
# Extract options and values from an ERB formatted config file
|
103
108
|
def cli_helper_process_erb(file_contents)
|
104
109
|
erb_contents = ERB.new(file_contents).result
|
105
110
|
return erb_contents
|
106
111
|
end
|
107
112
|
|
113
|
+
|
114
|
+
# Extract options and values from a YAML formatted config file
|
108
115
|
def cli_helper_process_yaml(file_contents='')
|
109
116
|
a_hash = YAML.load file_contents
|
110
117
|
return a_hash
|
111
118
|
end
|
112
119
|
|
120
|
+
|
121
|
+
# Extract options and values from an INI formated config file
|
113
122
|
def cli_helper_process_ini(file_contents='')
|
114
123
|
an_ini_object = IniFile.new(
|
115
124
|
content: file_contents,
|
@@ -120,6 +129,8 @@ module CliHelper
|
|
120
129
|
return an_ini_object.to_h
|
121
130
|
end
|
122
131
|
|
132
|
+
|
133
|
+
# Obtain options and values from a config file
|
123
134
|
def cli_helper_process_config_file(a_cf)
|
124
135
|
cf = String == a_cf.class ? Pathname.new(a_cf) : a_cf
|
125
136
|
if cf.directory?
|
@@ -184,8 +195,12 @@ module CliHelper
|
|
184
195
|
# parameters provided via a block. Create '?'
|
185
196
|
# for all boolean parameters that have a '--name' flag form.
|
186
197
|
# Returns a Slop::Options object
|
187
|
-
def cli_helper(my_banner=''
|
188
|
-
|
198
|
+
def cli_helper( my_banner='',
|
199
|
+
slop_options_config={}
|
200
|
+
)
|
201
|
+
default_config = { suppress_errors: configatron.suppress_errors }
|
202
|
+
|
203
|
+
param = Slop::Options.new( default_config.merge(slop_options_config) )
|
189
204
|
|
190
205
|
if my_banner.empty?
|
191
206
|
param.banner = "Usage: #{my_name} [options] ..."
|
@@ -233,8 +248,38 @@ module CliHelper
|
|
233
248
|
end
|
234
249
|
|
235
250
|
parser = Slop::Parser.new(param, suppress_errors: configatron.suppress_errors)
|
251
|
+
|
236
252
|
configatron.cli = parser.parse(ARGV)
|
237
253
|
|
254
|
+
# Lets do some error checking ...
|
255
|
+
configatron.cli.options.options.each do |opt|
|
256
|
+
if opt.count > 1
|
257
|
+
warning "#{opt.desc} #{opt.flags.inspect} entered more than once; only last value is used"
|
258
|
+
end
|
259
|
+
if opt.value.nil?
|
260
|
+
if opt.config.default.nil?
|
261
|
+
# NOTE: why is this a warning and not an error?
|
262
|
+
# while it may be required, it might be set in a config file
|
263
|
+
# so we let the user decide to continue or abort.
|
264
|
+
# SMELL: see below, past the loading of the config file values.
|
265
|
+
warning "Required parameter is missing: #{opt.desc} #{opt.flags.inspect}"
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
unless configatron.cli.arguments.empty?
|
271
|
+
bad_options = configatron.cli.arguments.select {|o| o.start_with?('-')}
|
272
|
+
unless bad_options.empty?
|
273
|
+
error "Invalid parameters: #{bad_options.inspect}"
|
274
|
+
bad_options.each do |o|
|
275
|
+
x = configatron.cli.arguments.index(o)
|
276
|
+
configatron.cli.arguments[x] = nil
|
277
|
+
end
|
278
|
+
configatron.cli.arguments.compact!
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
|
238
283
|
# NOTE: The config files are being process before the
|
239
284
|
# command line options in order for the command
|
240
285
|
# line options to over-write the values from the
|
@@ -245,6 +290,10 @@ module CliHelper
|
|
245
290
|
end # configatron.cli.config.each do |cf|
|
246
291
|
end # if configatron.enable_config_files
|
247
292
|
|
293
|
+
# SMELL: a required parameter that is not entered on the command line
|
294
|
+
# will have a value of nil. IF THAT parameter had been
|
295
|
+
# set in a config file, this will overlay the valid value
|
296
|
+
# with an invalid nil.
|
248
297
|
configatron.configure_from_hash(configatron.cli.to_hash)
|
249
298
|
configatron.arguments = configatron.cli.arguments
|
250
299
|
|
@@ -272,6 +321,7 @@ module CliHelper
|
|
272
321
|
return param
|
273
322
|
end # def cli_helper
|
274
323
|
|
324
|
+
|
275
325
|
# Returns the usage/help information as a string
|
276
326
|
def usage
|
277
327
|
a_string = configatron.cli.to_s + "\n"
|
@@ -279,13 +329,16 @@ module CliHelper
|
|
279
329
|
return a_string
|
280
330
|
end
|
281
331
|
|
332
|
+
|
282
333
|
# Prints to STDOUT the usage/help string
|
283
334
|
def show_usage
|
284
335
|
puts usage()
|
285
336
|
end
|
286
337
|
|
287
338
|
|
288
|
-
# Returns an array of valid files of
|
339
|
+
# Returns an array of valid files of valid type(s)
|
340
|
+
# Creates warnings for files not matching the valid extensions.
|
341
|
+
# Generates errors fpr files that do not exist
|
289
342
|
def get_pathnames_from(an_array, extnames=['.json', '.txt', '.docx'])
|
290
343
|
an_array = [an_array] unless an_array.is_a? Array
|
291
344
|
extnames = [extnames] unless extnames.is_a? Array
|
@@ -300,7 +353,7 @@ module CliHelper
|
|
300
353
|
if extnames.include?(pfn.extname.downcase)
|
301
354
|
file_array << pfn
|
302
355
|
else
|
303
|
-
|
356
|
+
warning "File ignored because extension is not #{extnames.join(' or ')} file: #{pfn}"
|
304
357
|
end
|
305
358
|
else
|
306
359
|
error "File does not exist: #{pfn}"
|
@@ -337,15 +390,29 @@ module CliHelper
|
|
337
390
|
end
|
338
391
|
end # def abort_if_errors
|
339
392
|
|
393
|
+
|
340
394
|
# Adds a string to the global $errors array
|
341
395
|
def error(a_string)
|
342
396
|
configatron.errors << a_string
|
343
397
|
end
|
344
398
|
|
399
|
+
|
400
|
+
# Returns an Array of errors
|
401
|
+
def errors
|
402
|
+
configatron.errors
|
403
|
+
end
|
404
|
+
|
405
|
+
|
345
406
|
# Adds a string to the global $warnings array
|
346
407
|
def warning(a_string)
|
347
408
|
configatron.warnings << a_string
|
348
409
|
end
|
349
410
|
|
411
|
+
|
412
|
+
# Returns an Array of warnings
|
413
|
+
def warnings
|
414
|
+
configatron.warnings
|
415
|
+
end
|
416
|
+
|
350
417
|
end # module CliHelper
|
351
418
|
|
data/tests/cli_helper_test.rb
CHANGED
@@ -160,9 +160,7 @@ end
|
|
160
160
|
|
161
161
|
|
162
162
|
|
163
|
-
|
164
|
-
|
165
|
-
#it '888 prints usage()' do
|
163
|
+
#it '060 prints usage()' do
|
166
164
|
puts
|
167
165
|
puts "="*45
|
168
166
|
show_usage
|
@@ -215,6 +213,102 @@ EOS
|
|
215
213
|
end
|
216
214
|
#end
|
217
215
|
|
216
|
+
#it '070 warns about multiple uses of a paramager on the command line' do
|
217
|
+
ARGV = "-n Tom -n Dick -n Harry".split
|
218
|
+
configatron.warnings = []
|
219
|
+
assert configatron.warnings.empty?
|
220
|
+
|
221
|
+
cli_helper do |o|
|
222
|
+
o.string '-n', '--name', 'Hello <name>'
|
223
|
+
end
|
224
|
+
|
225
|
+
assert_equal 1, configatron.warnings.size
|
226
|
+
assert configatron.warnings.first.include?('entered more than once; only last value is used')
|
227
|
+
#end
|
228
|
+
|
229
|
+
|
230
|
+
#it '080 warns about missiong value and undefined flag' do
|
231
|
+
ARGV = "--WooWho -n".split
|
232
|
+
configatron.warnings = []
|
233
|
+
configatron.errors = []
|
234
|
+
assert configatron.warnings.empty?
|
235
|
+
|
236
|
+
cli_helper do |o|
|
237
|
+
o.string '-n', '--name', 'Hello <name>'
|
238
|
+
end
|
239
|
+
|
240
|
+
assert_equal 1, configatron.warnings.size
|
241
|
+
assert_equal 'Required parameter is missing: Hello <name> ["-n", "--name"]', configatron.warnings.first
|
242
|
+
|
243
|
+
assert_equal 1, configatron.errors.size
|
244
|
+
assert_equal 'Invalid parameters: ["--WooWho"]', configatron.errors.first
|
245
|
+
#end
|
246
|
+
|
247
|
+
|
248
|
+
#it '090 generates exception' do
|
249
|
+
# Do not recommend using exceptions to communicate errors and warnings.
|
250
|
+
# because only one exception can be generated at a time. Its better to
|
251
|
+
# alert the user to all known problems than to just detect and report
|
252
|
+
# only one problem at a time.
|
253
|
+
|
254
|
+
ARGV = "--WooWho -n".split # This string has two errors but only one will be deteched.
|
255
|
+
configatron.warnings = []
|
256
|
+
configatron.errors = []
|
257
|
+
assert configatron.warnings.empty?
|
258
|
+
|
259
|
+
configatron.suppress_errors = false
|
260
|
+
|
261
|
+
exception_text = 'there was no exception'
|
262
|
+
|
263
|
+
begin
|
264
|
+
cli_helper do |o|
|
265
|
+
o.string '-n', '--name', 'Hello <name>'
|
266
|
+
end
|
267
|
+
rescue Exception => e
|
268
|
+
exception_text = e
|
269
|
+
end
|
270
|
+
|
271
|
+
assert_equal "unknown option `--WooWho'", exception_text
|
272
|
+
|
273
|
+
assert_equal 0, configatron.warnings.size
|
274
|
+
assert_equal 0, configatron.errors.size
|
275
|
+
#end
|
276
|
+
|
277
|
+
#it '092 generates exception' do
|
278
|
+
# Do not recommend using exceptions to communicate errors and warnings.
|
279
|
+
# because only one exception can be generated at a time. Its better to
|
280
|
+
# alert the user to all known problems than to just detect and report
|
281
|
+
# only one problem at a time.
|
282
|
+
|
283
|
+
# change the order from the previous test does not change the results
|
284
|
+
# because the first this that is checked by Slop is unknown flags. Then it checks
|
285
|
+
# for missing arguments in the remaining flags. Slop will generate an exception
|
286
|
+
# on the first error it finds. There is no way to cause Slop to resume checking
|
287
|
+
# the remaining command line parameters.
|
288
|
+
ARGV = "-n".split # This string has no unknown flags.
|
289
|
+
configatron.warnings = []
|
290
|
+
configatron.errors = []
|
291
|
+
assert configatron.warnings.empty?
|
292
|
+
|
293
|
+
configatron.suppress_errors = false
|
294
|
+
|
295
|
+
exception_text = 'there was no exception'
|
296
|
+
|
297
|
+
begin
|
298
|
+
cli_helper do |o|
|
299
|
+
o.string '-n', '--name', 'Hello <name>'
|
300
|
+
end
|
301
|
+
rescue Exception => e
|
302
|
+
exception_text = e
|
303
|
+
end
|
304
|
+
|
305
|
+
assert_equal "missing argument for -n, --name", exception_text
|
306
|
+
|
307
|
+
assert_equal 0, configatron.warnings.size
|
308
|
+
assert_equal 0, configatron.errors.size
|
309
|
+
#end
|
310
|
+
|
311
|
+
|
218
312
|
#it '999 Show the options structure' do
|
219
313
|
puts '*'*45
|
220
314
|
ap configatron.to_h
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cli_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dewayne VanHoozer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: configatron
|
@@ -58,42 +58,42 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '4.
|
61
|
+
version: '4.2'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '4.
|
68
|
+
version: '4.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: kick_the_tires
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|
203
203
|
rubyforge_project:
|
204
|
-
rubygems_version: 2.4
|
204
|
+
rubygems_version: 2.6.4
|
205
205
|
signing_key:
|
206
206
|
specification_version: 4
|
207
207
|
summary: An encapsulation of an integration of slop, nenv, inifile and configatron.
|