shellopts 2.0.11 → 2.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 485e81c58a890240d2a77e24a5f3a7a291551da968f395f3aaa4f5b2dac3cc9b
4
- data.tar.gz: 2d6c92ca01ce1207f6311cf9b0e9bab3e555e309142ba6916d589396f215afb8
3
+ metadata.gz: b2f378c7e7c04297221bfae81065ef06699e93b2dc4fda892b210ef4702c5836
4
+ data.tar.gz: f5d83b09b371aebd7cc07e73905edffb2f9f834ba5e382894277310e984e7ecc
5
5
  SHA512:
6
- metadata.gz: 31f3801b98585bed378ff77ae6632d18951ef37a49b3cfde843df9718dc5b46da40e777dff3f7b29e01bf8b32f2ebe0e1e7ab76ddb66744a461acf0061f75b1f
7
- data.tar.gz: d72bcf1d58e9afdf4f92477af1f2824e01031a46b4cacf5283878ce1045ad91dd930c1c1a15cd588a2552a4ad90fe5ac3add6019b50e099693aa184b7747153f
6
+ metadata.gz: 6255a64a99ceefe0dc0a7a3195976d42b2db6b3a28d779cbeefbc9f36380e46a762939e2062ff9f32f4f78bd5bff8122606b5102d9d8473e86c0a742cd7db479
7
+ data.tar.gz: b54f74a5d8fd251d1492667bd8e1340c1f17a3e96936f423efd61e82fe665294936c1edd1ac9ac4ab9df118450ccefafcda117f84ef4e0726d78159196e075cf
@@ -1,3 +1,3 @@
1
1
  module ShellOpts
2
- VERSION = "2.0.11"
2
+ VERSION = "2.0.12"
3
3
  end
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
- Formatter.usage(grammar)
201
- exit 1
202
- ensure
203
- $stdout = saved
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 is supposed to be used the used specified the correct arguments
209
- # but something went wrong during processing. Since the used didn't cause
210
- # the problem, only the error message is written
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
- forward_self_to :instance, :error, :failure
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.11
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-14 00:00:00.000000000 Z
11
+ date: 2022-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forward_to