shellopts 2.0.11 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/shellopts/version.rb +1 -1
- data/lib/shellopts.rb +22 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2f378c7e7c04297221bfae81065ef06699e93b2dc4fda892b210ef4702c5836
|
4
|
+
data.tar.gz: f5d83b09b371aebd7cc07e73905edffb2f9f834ba5e382894277310e984e7ecc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6255a64a99ceefe0dc0a7a3195976d42b2db6b3a28d779cbeefbc9f36380e46a762939e2062ff9f32f4f78bd5bff8122606b5102d9d8473e86c0a742cd7db479
|
7
|
+
data.tar.gz: b54f74a5d8fd251d1492667bd8e1340c1f17a3e96936f423efd61e82fe665294936c1edd1ac9ac4ab9df118450ccefafcda117f84ef4e0726d78159196e075cf
|
data/lib/shellopts/version.rb
CHANGED
data/lib/shellopts.rb
CHANGED
@@ -192,23 +192,23 @@ module ShellOpts
|
|
192
192
|
#
|
193
193
|
# #error is supposed to be used when the user made an error and the usage
|
194
194
|
# is written to help correcting the error
|
195
|
-
#
|
196
195
|
def error(subject = nil, message)
|
197
|
-
saved = $stdout
|
198
|
-
$stdout = $stderr
|
199
196
|
$stderr.puts "#{name}: #{message}"
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
197
|
+
saved = $stdout
|
198
|
+
begin
|
199
|
+
$stdout = $stderr
|
200
|
+
Formatter.usage(grammar)
|
201
|
+
exit 1
|
202
|
+
ensure
|
203
|
+
$stdout = saved
|
204
|
+
end
|
204
205
|
end
|
205
206
|
|
206
207
|
# Write error message to standard error and terminate program with status 1
|
207
208
|
#
|
208
|
-
# #failure
|
209
|
-
#
|
210
|
-
#
|
211
|
-
#
|
209
|
+
# #failure doesn't print the program usage because is supposed to be used
|
210
|
+
# when the user specified the correct arguments but something else went
|
211
|
+
# wrong during processing
|
212
212
|
def failure(message)
|
213
213
|
$stderr.puts "#{name}: #{message}"
|
214
214
|
exit 1
|
@@ -222,7 +222,6 @@ module ShellOpts
|
|
222
222
|
|
223
223
|
# Print help for the given subject or the full documentation if +subject+
|
224
224
|
# is nil. Clears the screen beforehand if :clear is true
|
225
|
-
#
|
226
225
|
def help(subject = nil, clear: true)
|
227
226
|
node = (subject ? @grammar[subject] : @grammar) or
|
228
227
|
raise ArgumentError, "No such command: '#{subject&.sub(".", " ")}'"
|
@@ -333,7 +332,17 @@ module ShellOpts
|
|
333
332
|
def self.instance=(instance) @instance = instance end
|
334
333
|
def self.shellopts() instance end
|
335
334
|
|
336
|
-
|
335
|
+
def self.error(subject = nil, message)
|
336
|
+
instance.error(subject, message) if instance? # Never returns
|
337
|
+
$stderr.puts "#{File.basename($PROGRAM_NAME)}: #{message}"
|
338
|
+
exit 1
|
339
|
+
end
|
340
|
+
|
341
|
+
def self.failure(message)
|
342
|
+
instance.failure(message) if instance?
|
343
|
+
$stderr.puts "#{File.basename($PROGRAM_NAME)}: #{message}"
|
344
|
+
exit 1
|
345
|
+
end
|
337
346
|
|
338
347
|
# The Include module brings the reporting methods into the namespace when
|
339
348
|
# included
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shellopts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: forward_to
|