completely 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/lib/completely/commands/base.rb +2 -2
- data/lib/completely/commands/generate.rb +5 -5
- data/lib/completely/commands/test.rb +2 -29
- data/lib/completely/templates/template.erb +2 -5
- data/lib/completely/templates/tester-template.erb +0 -1
- data/lib/completely/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2012c5d2e6bdbdc4105a86bb535bcaacec54623b75ed4a68dfed59d7283b806f
|
4
|
+
data.tar.gz: 35b022231df795d3820c3c22df622351a83c8c5720becde6ce4cde05cccb5643
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cabb44f5d2e22d3fcaf2dba81c8bcca443f3ae06ce2201023cd7babd2f93792c754e97d1816a649b23139cb0b89d1ed4a23cbe875774cfa6f68bd0f055dfeb68
|
7
|
+
data.tar.gz: 9c74a483866d9b1b487f721d8ea19ea8523906986992d7df64b2b96945898ba667641c9d849f23ccdb9453635ecf088f1651b7d8346566eb7fd461fa4e76e170
|
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
|
@@ -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
|
|
@@ -9,8 +9,6 @@ module Completely
|
|
9
9
|
This command can be used to test that any completion script (either generated by compeltely or not) responds with the right completions.
|
10
10
|
|
11
11
|
In order to test on a completely configuration file other than 'completely.yaml', set the COMPLETELY_CONFIG_PATH environemnt variable.
|
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
12
|
EOF
|
15
13
|
|
16
14
|
usage "completely test COMPLINE"
|
@@ -19,21 +17,12 @@ module Completely
|
|
19
17
|
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
18
|
|
21
19
|
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
20
|
environment_debug
|
25
21
|
|
26
22
|
example %q[completely test "mygit pu"]
|
27
23
|
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
24
|
|
35
25
|
def run
|
36
|
-
set_vars
|
37
26
|
puts tester.test(compline).join "\n"
|
38
27
|
end
|
39
28
|
|
@@ -44,26 +33,10 @@ module Completely
|
|
44
33
|
end
|
45
34
|
|
46
35
|
def tester
|
47
|
-
|
48
|
-
|
49
|
-
completions.tester
|
50
|
-
else
|
51
|
-
Tester.new script_path: script_path, function_name: script_function
|
52
|
-
end
|
36
|
+
completions = Completions.load config_path
|
37
|
+
completions.tester
|
53
38
|
end
|
54
39
|
|
55
|
-
def set_vars
|
56
|
-
if ENV['COMPLETELY_CONFIG_PATH']
|
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
|
66
|
-
end
|
67
40
|
end
|
68
41
|
end
|
69
42
|
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
|
data/lib/completely/version.rb
CHANGED