completely 0.4.0 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -2
- data/lib/completely/commands/base.rb +2 -2
- data/lib/completely/commands/generate.rb +5 -5
- data/lib/completely/commands/test.rb +16 -34
- data/lib/completely/templates/template.erb +3 -6
- data/lib/completely/templates/tester-template.erb +12 -3
- data/lib/completely/tester.rb +1 -1
- data/lib/completely/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 207f7cf5e1b259c6cb7e9006f59cbf22b2096456707ef8d42edddbc6b0dc4e4e
|
4
|
+
data.tar.gz: 51e59317f307d3da3e09f7a30092970607000be5c7a11e4276e378dd0a41bb78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4eaaacc3785c367510802ad2945057d1ecc50fbfd8ddbcba08234a80b73c12adbe6157c0fd9726e9eb2a9f043470bccac9fdd45bea767edce94b4b47e0dc6912
|
7
|
+
data.tar.gz: fc79892cbbe2647aa5647ea68d6fe29ef3b91b0686565e16ce9e6c784157539ab728dce24c4991234c1a1756facca1b0aa019c9654a1fa90b91a7d8476ea3de8
|
data/README.md
CHANGED
@@ -217,8 +217,7 @@ these (whichever exists):
|
|
217
217
|
|
218
218
|
You can use the built in completions script tester by running `completely test`.
|
219
219
|
|
220
|
-
This command lets you test
|
221
|
-
completely or not.
|
220
|
+
This command lets you test completions for your completions script.
|
222
221
|
|
223
222
|
In addition, you can set the `COMPLETELY_DEBUG` environment variable to any value
|
224
223
|
in order to generate scripts with some additional debugging functionality. Run
|
@@ -251,6 +250,17 @@ puts completions.wrapper_function "custom_function_name"
|
|
251
250
|
p completions.tester.test "mygit status "
|
252
251
|
```
|
253
252
|
|
253
|
+
## Completions in ZSH
|
254
|
+
|
255
|
+
If you are using Oh-My-Zsh, bash completions should already be enabled,
|
256
|
+
otherwise, you should enable completion by adding this to your `~/.zshrc`
|
257
|
+
(if is it not already there):
|
258
|
+
|
259
|
+
```bash
|
260
|
+
# Load completion functions
|
261
|
+
autoload -Uz +X compinit && compinit
|
262
|
+
autoload -Uz +X bashcompinit && bashcompinit
|
263
|
+
```
|
254
264
|
|
255
265
|
## Contributing / Support
|
256
266
|
|
@@ -36,8 +36,8 @@ module Completely
|
|
36
36
|
@config_path ||= args['CONFIG_PATH'] || ENV['COMPLETELY_CONFIG_PATH'] || 'completely.yaml'
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
@
|
39
|
+
def output_path
|
40
|
+
@output_path ||= args['OUTPUT_PATH'] || ENV['COMPLETELY_OUTPUT_PATH'] || "#{config_basename}.bash"
|
41
41
|
end
|
42
42
|
|
43
43
|
def config_basename
|
@@ -5,24 +5,24 @@ module Completely
|
|
5
5
|
class Generate < Base
|
6
6
|
help "Generate the bash completion script to a file"
|
7
7
|
|
8
|
-
usage "completely generate [CONFIG_PATH
|
8
|
+
usage "completely generate [CONFIG_PATH OUTPUT_PATH --function NAME --wrap NAME]"
|
9
9
|
usage "completely generate (-h|--help)"
|
10
10
|
|
11
11
|
option_function
|
12
12
|
option "-w --wrap NAME", "Wrap the completion script inside a function that echos the script. This is useful if you wish to embed it directly in your script"
|
13
13
|
|
14
14
|
param_config_path
|
15
|
-
param "
|
15
|
+
param "OUTPUT_PATH", "Path to the output bash script. When not provided, the name of the input file will be used with a .bash extension\nCan also be set by an environment variable"
|
16
16
|
|
17
17
|
environment_config_path
|
18
|
-
environment "
|
18
|
+
environment "COMPLETELY_OUTPUT_PATH", "Path to the output bash script"
|
19
19
|
environment_debug
|
20
20
|
|
21
21
|
def run
|
22
22
|
wrap = args['--wrap']
|
23
23
|
output = wrap ? wrapper_function(wrap) : script
|
24
|
-
File.write
|
25
|
-
say "Saved !txtpur!#{
|
24
|
+
File.write output_path, output
|
25
|
+
say "Saved !txtpur!#{output_path}"
|
26
26
|
syntax_warning unless completions.valid?
|
27
27
|
end
|
28
28
|
|
@@ -5,36 +5,27 @@ module Completely
|
|
5
5
|
class Test < Base
|
6
6
|
summary "Test completions"
|
7
7
|
|
8
|
-
help
|
9
|
-
This command can be used to test that any completion script (either generated by compeltely or not) responds with the right completions.
|
8
|
+
help "This command can be used to test that your completions script responds with the right completions. It works by reading your completely.yaml file, generating a completions script, and generating a temporary testing script."
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
In order to test on an arbitrary completions script, set the COMPLETELY_SCRIPT_PATH and optionally the COMPLETELY_SCRIPT_FUNCTION environment variables.
|
14
|
-
EOF
|
15
|
-
|
16
|
-
usage "completely test COMPLINE"
|
10
|
+
usage "completely test [--keep] COMPLINE"
|
17
11
|
usage "completely test (-h|--help)"
|
18
12
|
|
13
|
+
option "-k --keep", "Keep the temporary testing script in the current directory"
|
14
|
+
|
19
15
|
param "COMPLINE", "The command to test completions for. This will be handled as if a TAB was pressed immediately at the end of it, so the last word is considered the active cursor. If you wish to complete for the next word instead, end your command with a space."
|
20
16
|
|
21
17
|
environment_config_path
|
22
|
-
environment "COMPLETELY_SCRIPT_PATH", "Path to a completions script. When set, this script will be tested instead of the completely configuration file"
|
23
|
-
environment "COMPLETELY_SCRIPT_FUNCTION", "The main completion function to call when using a custom script. If not set, the basename of the script path will be used, prefixed by an underscore"
|
24
18
|
environment_debug
|
25
19
|
|
26
20
|
example %q[completely test "mygit pu"]
|
27
21
|
example %q[completely test "mygit pull "]
|
28
|
-
example <<~EOF
|
29
|
-
COMPLETELY_SCRIPT_PATH=/usr/share/bash-completion/completions/chown \\
|
30
|
-
completely test "chown --"
|
31
|
-
EOF
|
32
|
-
|
33
|
-
attr_reader :config, :script_path, :script_function
|
34
22
|
|
35
23
|
def run
|
36
|
-
set_vars
|
37
24
|
puts tester.test(compline).join "\n"
|
25
|
+
if args['--keep']
|
26
|
+
File.write 'completely-tester.sh', tester_script
|
27
|
+
puts 'saved completely-tester.sh'
|
28
|
+
end
|
38
29
|
end
|
39
30
|
|
40
31
|
private
|
@@ -43,27 +34,18 @@ module Completely
|
|
43
34
|
args['COMPLINE']
|
44
35
|
end
|
45
36
|
|
37
|
+
def completions
|
38
|
+
@completions ||= Completions.load config_path
|
39
|
+
end
|
40
|
+
|
46
41
|
def tester
|
47
|
-
|
48
|
-
completions = Completions.load config
|
49
|
-
completions.tester
|
50
|
-
else
|
51
|
-
Tester.new script_path: script_path, function_name: script_function
|
52
|
-
end
|
42
|
+
@tester ||= completions.tester
|
53
43
|
end
|
54
44
|
|
55
|
-
def
|
56
|
-
|
57
|
-
@config = ENV['COMPLETELY_CONFIG_PATH']
|
58
|
-
elsif ENV['COMPLETELY_SCRIPT_PATH']
|
59
|
-
@script_path = ENV['COMPLETELY_SCRIPT_PATH']
|
60
|
-
@script_function = ENV['COMPLETELY_SCRIPT_FUNCTION'] || "_#{File.basename(script_path)}"
|
61
|
-
elsif File.exist? 'completely.yaml'
|
62
|
-
@config = 'completely.yaml'
|
63
|
-
else
|
64
|
-
raise "Please set the proper environment variables or run in a folder with completely.yaml"
|
65
|
-
end
|
45
|
+
def tester_script
|
46
|
+
@tester_script ||= tester.tester_script compline
|
66
47
|
end
|
48
|
+
|
67
49
|
end
|
68
50
|
end
|
69
51
|
end
|
@@ -5,11 +5,8 @@
|
|
5
5
|
# Modifying it manually is not recommended
|
6
6
|
|
7
7
|
<%= function_name %>() {
|
8
|
-
local cur
|
9
|
-
|
10
|
-
|
11
|
-
cur=${COMP_WORDS[COMP_CWORD]}
|
12
|
-
compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}"
|
8
|
+
local cur=${COMP_WORDS[COMP_CWORD]}
|
9
|
+
local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}"
|
13
10
|
|
14
11
|
% if ENV['COMPLETELY_DEBUG']
|
15
12
|
if [[ -n "$COMPLETELY_DEBUG" ]]; then
|
@@ -22,7 +19,7 @@
|
|
22
19
|
% patterns.each do |pattern|
|
23
20
|
% next if pattern.empty?
|
24
21
|
<%= pattern.case_string %>)
|
25
|
-
COMPREPLY
|
22
|
+
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen <%= pattern.compgen %> -- "$cur" )
|
26
23
|
;;
|
27
24
|
|
28
25
|
% end
|
@@ -1,13 +1,22 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
|
+
if [[ -n $ZSH_VERSION ]]; then
|
3
|
+
autoload -U +X bashcompinit && bashcompinit
|
4
|
+
autoload -U +X compinit && compinit
|
5
|
+
fi
|
6
|
+
|
7
|
+
# === COMPLETION SCRIPT START ===
|
8
|
+
|
2
9
|
<%= script || %Q[source "#{absolute_script_path}"] %>
|
3
10
|
|
4
|
-
#
|
11
|
+
# === COMPLETION SCRIPT END ===
|
5
12
|
|
6
|
-
source /usr/share/bash-completion/bash_completion
|
7
13
|
COMP_WORDS=( <%= compline %> )
|
8
14
|
COMP_LINE="<%= compline %>"
|
9
15
|
COMP_POINT=${#COMP_LINE}
|
10
16
|
COMP_CWORD=<%= cword %>
|
11
17
|
|
12
18
|
<%= function_name %>
|
13
|
-
|
19
|
+
for suggestion in "${COMPREPLY[@]}"; do
|
20
|
+
echo "$suggestion"
|
21
|
+
done
|
22
|
+
|
data/lib/completely/tester.rb
CHANGED
data/lib/completely/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: completely
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
|
-
rubygems_version: 3.3.
|
83
|
+
rubygems_version: 3.3.14
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Bash Completions Generator
|