docopt-compgen 1.3.1 → 1.5.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 +12 -2
- data/lib/docopt_compgen/generator.rb +3 -2
- data/lib/docopt_compgen/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb0c497d240588d088c975448cdf72354f26bbb7eaf093f7f49d605f9fd605ed
|
4
|
+
data.tar.gz: b00a7f2e4b0cd01bcf9886ddc018012ee3ea7b44969099ddce3ff6b27ff7204b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5d2b99b19724d97ed7ddba682b953452d936e76baa30818ec66f2346fe0b5b80807d2eb6567d09f5732c9d89b9e1dc22a10c537f734ed94206bf963113b2441
|
7
|
+
data.tar.gz: 2e0700092b8aa3c663a5434c86d7370af24734293d162427889cd2acd62e8d658a26ee8d201bdd4ad2872c7a52d00c22fac427f6c9b23a764409a7b629a0f355
|
data/bin/docopt-compgen
CHANGED
@@ -2,16 +2,19 @@
|
|
2
2
|
trap(:SIGINT) { puts; exit 130 }
|
3
3
|
Signal.trap(:SIGPIPE, :SYSTEM_DEFAULT)
|
4
4
|
require 'docopt'
|
5
|
+
PROGRAM_NAME = File.basename($PROGRAM_NAME)
|
5
6
|
|
6
7
|
usage = <<~EOF
|
7
8
|
Usage:
|
8
|
-
#{
|
9
|
+
#{PROGRAM_NAME} [options] [<command>]
|
9
10
|
|
10
11
|
Options:
|
12
|
+
-o, --out PATH Output completion to PATH instead of stdout
|
11
13
|
--complete-short Complete short options (long options are always completed)
|
12
14
|
--command-name NAME Command name
|
13
15
|
If not specified then the slugified basename of <command> will be used
|
14
16
|
--namespace NAME Prefix for generated bash functions [default: cmd]
|
17
|
+
--header TEXT Header to insert at the start of the completion script
|
15
18
|
-v, --version Show version
|
16
19
|
-h, --help Show help
|
17
20
|
EOF
|
@@ -74,6 +77,13 @@ generator = DocoptCompgen::Generator.new(
|
|
74
77
|
parser.to_node,
|
75
78
|
command_name: command_name,
|
76
79
|
namespace: opts['--namespace'],
|
80
|
+
header: opts['--header'],
|
77
81
|
)
|
78
82
|
|
79
|
-
|
83
|
+
output = generator.to_s
|
84
|
+
|
85
|
+
if opts['--out']
|
86
|
+
File.write(opts['--out'], output)
|
87
|
+
else
|
88
|
+
puts output
|
89
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module DocoptCompgen
|
2
2
|
class Generator
|
3
|
-
def initialize(command, node, command_name: nil, namespace: nil)
|
3
|
+
def initialize(command, node, command_name: nil, namespace: nil, header: nil)
|
4
4
|
@command = command ? File.basename(command) : command_name
|
5
5
|
@node = node
|
6
6
|
@command_name = command_name || Util.slugify(@command)
|
7
7
|
@namespace = '_' + namespace
|
8
|
+
@header = header
|
8
9
|
end
|
9
10
|
|
10
11
|
def indent(str, level)
|
@@ -119,7 +120,7 @@ module DocoptCompgen
|
|
119
120
|
return <<~EOF
|
120
121
|
#!/bin/bash
|
121
122
|
# shellcheck disable=SC2207
|
122
|
-
|
123
|
+
#{@header ? @header + "\n" : ''}
|
123
124
|
#{content}
|
124
125
|
complete -o bashdefault -o default -o filenames -F #{@namespace}_#{@command_name} #{@command}
|
125
126
|
EOF
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- crdx
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -68,7 +68,7 @@ files:
|
|
68
68
|
- lib/docopt_compgen/version.rb
|
69
69
|
homepage: https://github.com/crdx/docopt-compgen
|
70
70
|
licenses:
|
71
|
-
-
|
71
|
+
- GPLv3
|
72
72
|
metadata:
|
73
73
|
rubygems_mfa_required: 'true'
|
74
74
|
post_install_message:
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
|
-
rubygems_version: 3.
|
89
|
+
rubygems_version: 3.3.25
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: docopt completion generator
|