docopt-compgen 1.3.1 → 1.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a600e6b18676edfb5f2df11888e7f81513e3943a3891f2a30ea282a6fb89981
4
- data.tar.gz: 1780dba9257aa22199a031bcede2c9454941cff25bbb1727328982c44f8f6121
3
+ metadata.gz: bb0c497d240588d088c975448cdf72354f26bbb7eaf093f7f49d605f9fd605ed
4
+ data.tar.gz: b00a7f2e4b0cd01bcf9886ddc018012ee3ea7b44969099ddce3ff6b27ff7204b
5
5
  SHA512:
6
- metadata.gz: 793e00800a729bf477fb106893f817e0646b77966d0bf8b302c9ac0fea41b2914fe1a22e96b59f7da2f93b9eef5a10f369ae39d622d1ed877eafc7cbbfebdbd4
7
- data.tar.gz: 5aaf2d78a18eabb4c8df1b5bb28d7ba34cd271570925e36aa40fb4b2f3683d9b930ddd468d4442fc0f5f55e5b2d9436e308ea950f7f037c27c0f522da4b13715
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
- #{File.basename($0)} [options] [<command>]
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
- puts generator.to_s
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
@@ -1,3 +1,3 @@
1
1
  module DocoptCompgen
2
- VERSION = '1.3.1'
2
+ VERSION = '1.5.0'
3
3
  end
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.3.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: 2021-11-17 00:00:00.000000000 Z
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
- - MIT
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.2.29
89
+ rubygems_version: 3.3.25
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: docopt completion generator