docopt_ng 0.7.0 → 0.7.1

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: 4ee12e3238546070b62a14408b24689dda48af1067ed5d139f3795a5cee2f9b9
4
- data.tar.gz: 49082568fa660901f429539174e0826456d02d4efda581c09a1ecd1d53dd6276
3
+ metadata.gz: 282dad6ddba08232bfa05366b102d00becb64526eb466e94241ee9913385c1cc
4
+ data.tar.gz: 2aad8088c5f6284e850ffac748dd3faa3fbc5fa02045e0a10188fcc9361af2c3
5
5
  SHA512:
6
- metadata.gz: f78d00cfe0a68f4ce42f5c224ceb631bfcfe728a741babd65242443efc8f754a763c2caff34fedeed83ee4902813752b2e9a297da9019581182505f5fe555420
7
- data.tar.gz: 269e933d636bc8b05ed19a51b0eef742611b6413205c64b2d156458d290d3cbe6f15c78b6ea3807582a60aec8a3681dd829a6ae0893f2e28f693106c466336ed
6
+ metadata.gz: 115b8b73b9083bf36d77e43cb8fb622beb5d88cb500e678971734811426f7af2741a08e2d95671eb666c5d0a212dbb7d3eeeb654664126f3ad78400314229a24
7
+ data.tar.gz: 328228a0a1325fa16091df4d4bb52aae0bc9c8e3d0d4cf9934cabd2bb6a18cd3d618af465c95184ee43d16c2ad86d8c1e08d3ed296ee196171b12d7ea297edd3
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Docopt – command line option parser, that will make you smile
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/docopt_ng.svg)](https://badge.fury.io/rb/docopt_ng)
4
+ [![Build Status](https://github.com/DannyBen/docopt_ng/workflows/Test/badge.svg)](https://github.com/DannyBen/docopt_ng/actions?query=workflow%3ATest)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/31af96bab7913f71dc28/maintainability)](https://codeclimate.com/github/DannyBen/docopt_ng/maintainability)
6
+
3
7
  ---
4
8
 
5
9
  This is a detached fork of the original [docopt.rb](https://github.com/docopt/docopt.rb).
@@ -46,9 +50,10 @@ Options:
46
50
  DOCOPT
47
51
 
48
52
  begin
49
- pp Docopt::docopt(doc)
53
+ pp Docopt.docopt(doc)
50
54
  rescue Docopt::Exit => e
51
55
  puts e.message
56
+ exit e.exit_code
52
57
  end
53
58
  ```
54
59
 
@@ -6,12 +6,15 @@ module DocoptNG
6
6
  class << self
7
7
  attr_reader :usage
8
8
 
9
- def set_usage(text = nil)
9
+ def usage=(text)
10
10
  @usage = text || ''
11
11
  end
12
12
  end
13
13
 
14
- def initialize(message = '')
14
+ attr_reader :exit_code
15
+
16
+ def initialize(message = '', exit_code: nil)
17
+ @exit_code = exit_code || 1
15
18
  super "#{message}\n#{self.class.usage}".strip
16
19
  end
17
20
  end
@@ -1,3 +1,3 @@
1
1
  module DocoptNG
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
data/lib/docopt_ng.rb CHANGED
@@ -253,13 +253,13 @@ module_function
253
253
  def extras(help, version, options, doc)
254
254
  help_flags = ['-h', '--help']
255
255
  if help && options.any? { |o| help_flags.include?(o.name) && o.value }
256
- Exit.set_usage(nil)
257
- raise Exit, doc.strip
256
+ Exit.usage = nil
257
+ raise Exit.new(exit_code: 0), doc.strip
258
258
  end
259
259
  return unless version && options.any? { |o| o.name == '--version' && o.value }
260
260
 
261
- Exit.set_usage(nil)
262
- raise Exit, version
261
+ Exit.usage = nil
262
+ raise Exit.new(exit_code: 0), version
263
263
  end
264
264
 
265
265
  def docopt(doc, params = {})
@@ -267,7 +267,7 @@ module_function
267
267
  params = default.merge(params)
268
268
  params[:argv] = ARGV unless params[:argv]
269
269
 
270
- Exit.set_usage(printable_usage(doc))
270
+ Exit.usage = printable_usage(doc)
271
271
  options = parse_defaults(doc)
272
272
  pattern = parse_pattern(formal_usage(Exit.usage), options)
273
273
  argv = parse_argv(TokenStream.new(params[:argv], Exit), options, params[:options_first])
@@ -285,6 +285,6 @@ module_function
285
285
  return (pattern.flat + collected).to_h { |a| [a.name, a.value] }
286
286
  end
287
287
 
288
- raise Exit
288
+ raise Exit.new
289
289
  end
290
290
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docopt_ng
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Williams
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2023-02-02 00:00:00.000000000 Z
15
+ date: 2023-02-17 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description: Parse command line arguments from nothing more than a usage message
18
18
  email: db@dannyben.com
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  requirements: []
64
- rubygems_version: 3.4.6
64
+ rubygems_version: 3.4.7
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: A command line option parser that will make you smile