docopt-compgen 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/docopt-compgen +17 -10
- data/lib/docopt-compgen/version.rb +1 -1
- 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: 7c87d112789dd4ea1b0830ab3c5d004bf4e56fd42565de0c058cc3245ad9c58d
|
4
|
+
data.tar.gz: 1145fcc4bab68d7414deab14eceae576cc2902d8b35155219c47990171907d21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52cfc2f51e175ad014c4c575eb5da8cdaab2e1e2e8ad7473c0a6827d2c5775f68d9ae9a6782034c505d87abb4d5ba9a7f27c204fc52e660d651458360c06be43
|
7
|
+
data.tar.gz: eba600aa23409e5a9ee18c72991c32f1e5ed5a82805afc3f5943c9fd2fde3549f21cdc915904b62915677be006ae27f4a5fad90ff64cec5d9b4e474dbb676539
|
data/bin/docopt-compgen
CHANGED
@@ -23,6 +23,11 @@ end
|
|
23
23
|
|
24
24
|
require 'colorize'
|
25
25
|
|
26
|
+
def extract_command_name(usage)
|
27
|
+
matches = /Usage:\s*(\S+)/.match(usage)
|
28
|
+
matches[1] if matches
|
29
|
+
end
|
30
|
+
|
26
31
|
if $stdin.tty?
|
27
32
|
command = opts['<command>']
|
28
33
|
if command.nil?
|
@@ -32,33 +37,35 @@ if $stdin.tty?
|
|
32
37
|
end
|
33
38
|
|
34
39
|
begin
|
35
|
-
|
40
|
+
usage = `#{command} --help`
|
36
41
|
rescue => e
|
37
42
|
$stderr.puts e.to_s.red
|
38
43
|
exit 1
|
39
44
|
end
|
45
|
+
|
46
|
+
command_name = opts['--command-name']
|
40
47
|
else
|
41
|
-
|
42
|
-
|
43
|
-
|
48
|
+
usage = $stdin.read
|
49
|
+
command_name = extract_command_name(usage)
|
50
|
+
|
51
|
+
if command_name.nil?
|
52
|
+
$stderr.puts 'Error: Unable to parse command name from usage output'.red
|
44
53
|
exit 1
|
45
54
|
end
|
46
|
-
|
47
|
-
help = $stdin.read
|
48
55
|
end
|
49
56
|
|
50
|
-
if
|
51
|
-
$stderr.puts 'Unable to parse
|
57
|
+
if usage.nil? || usage.lines.first !~ /Usage:/
|
58
|
+
$stderr.puts 'Unable to parse usage output from "%s"'.red % command
|
52
59
|
exit 1
|
53
60
|
end
|
54
61
|
|
55
62
|
require_relative '../lib/docopt-compgen'
|
56
63
|
|
57
|
-
parser = DocoptCompgen::Parser.new(
|
64
|
+
parser = DocoptCompgen::Parser.new(usage)
|
58
65
|
generator = DocoptCompgen::Generator.new(
|
59
66
|
command,
|
60
67
|
parser.to_node,
|
61
|
-
command_name:
|
68
|
+
command_name: command_name,
|
62
69
|
namespace: opts['--namespace'],
|
63
70
|
)
|
64
71
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docopt-compgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- crdx
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|