completely 0.5.1 → 0.5.2
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 +4 -4
- data/lib/completely/commands/base.rb +11 -4
- data/lib/completely/commands/generate.rb +8 -3
- data/lib/completely/commands/test.rb +34 -15
- data/lib/completely/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: 7928212af575e203b41b2b6a1c94a0f6f564c28ae44795ade142b41ed83cbfe7
|
4
|
+
data.tar.gz: 541bd497455eedd5b0114edb7913ed1ccb1d2cfc90d78ca6d45298864f210583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cccadd0753d2ba83700f9bdebbd8e29eb3519206bb99992636fdde98cc313107b6475b8c12291dac3be8cbfc9ee235fa59c512dd55b62c2d8027ab871d8d424c
|
7
|
+
data.tar.gz: 36997d82e3438909788eb70484aabcaebe7a37534039ce748c1f3257aef05a674a8a9110280b3b324622eea1ff749263ea2a9968e31708be050676549536efcb
|
@@ -5,19 +5,26 @@ module Completely
|
|
5
5
|
class Base < MisterBin::Command
|
6
6
|
class << self
|
7
7
|
def param_config_path
|
8
|
-
param 'CONFIG_PATH',
|
8
|
+
param 'CONFIG_PATH', <<~USAGE
|
9
|
+
Path to the YAML configuration file [default: completely.yaml].
|
10
|
+
Can also be set by an environment variable.
|
11
|
+
USAGE
|
9
12
|
end
|
10
13
|
|
11
14
|
def option_function
|
12
|
-
option '-f --function NAME',
|
15
|
+
option '-f --function NAME',
|
16
|
+
'Modify the name of the function in the generated script.'
|
13
17
|
end
|
14
18
|
|
15
19
|
def environment_config_path
|
16
|
-
environment 'COMPLETELY_CONFIG_PATH',
|
20
|
+
environment 'COMPLETELY_CONFIG_PATH',
|
21
|
+
'Path to a completely configuration file [default: completely.yaml].'
|
17
22
|
end
|
18
23
|
|
19
24
|
def environment_debug
|
20
|
-
environment 'COMPLETELY_DEBUG', '
|
25
|
+
environment 'COMPLETELY_DEBUG', 'If not empty, the generated script will include ' \
|
26
|
+
'an additional debugging snippet that outputs the compline and current word to ' \
|
27
|
+
'a text file when a completion is requested.'
|
21
28
|
end
|
22
29
|
end
|
23
30
|
|
@@ -9,13 +9,18 @@ module Completely
|
|
9
9
|
usage 'completely generate (-h|--help)'
|
10
10
|
|
11
11
|
option_function
|
12
|
-
option '-w --wrap NAME', 'Wrap the completion script inside a function that echos the
|
12
|
+
option '-w --wrap NAME', 'Wrap the completion script inside a function that echos the ' \
|
13
|
+
'script. This is useful if you wish to embed it directly in your script.'
|
13
14
|
|
14
15
|
param_config_path
|
15
|
-
param 'OUTPUT_PATH',
|
16
|
+
param 'OUTPUT_PATH', <<~USAGE
|
17
|
+
Path to the output bash script.
|
18
|
+
When not provided, the name of the input file will be used with a .bash extension.
|
19
|
+
Can also be set by an environment variable.
|
20
|
+
USAGE
|
16
21
|
|
17
22
|
environment_config_path
|
18
|
-
environment 'COMPLETELY_OUTPUT_PATH', 'Path to the output bash script'
|
23
|
+
environment 'COMPLETELY_OUTPUT_PATH', 'Path to the output bash script.'
|
19
24
|
environment_debug
|
20
25
|
|
21
26
|
def run
|
@@ -5,27 +5,30 @@ module Completely
|
|
5
5
|
class Test < Base
|
6
6
|
summary 'Test completions'
|
7
7
|
|
8
|
-
help 'This command can be used to test that your completions script responds with
|
8
|
+
help 'This command can be used to test that your completions script responds with ' \
|
9
|
+
'the right completions. It works by reading your completely.yaml file, generating ' \
|
10
|
+
'a completions script, and generating a temporary testing script.'
|
9
11
|
|
10
|
-
usage 'completely test [--keep] COMPLINE'
|
12
|
+
usage 'completely test [--keep] COMPLINE...'
|
11
13
|
usage 'completely test (-h|--help)'
|
12
14
|
|
13
|
-
option '-k --keep', 'Keep the temporary testing script in the current directory'
|
15
|
+
option '-k --keep', 'Keep the temporary testing script in the current directory.'
|
14
16
|
|
15
|
-
param 'COMPLINE', '
|
17
|
+
param 'COMPLINE', 'One or more commands to test completions for. ' \
|
18
|
+
'This will be handled as if a TAB was pressed immediately at the end of it, ' \
|
19
|
+
'so the last word is considered the active cursor. ' \
|
20
|
+
'If you wish to complete for the next word instead, end your command with a space.'
|
16
21
|
|
17
22
|
environment_config_path
|
18
23
|
environment_debug
|
19
24
|
|
20
|
-
example 'completely test "mygit
|
21
|
-
example 'completely test "mygit
|
25
|
+
example 'completely test "mygit "'
|
26
|
+
example 'completely test --keep "mygit status "'
|
27
|
+
example 'completely test "mygit status --" "mygit init "'
|
22
28
|
|
23
29
|
def run
|
24
|
-
|
25
|
-
|
26
|
-
if args['--keep']
|
27
|
-
File.write 'completely-tester.sh', tester_script
|
28
|
-
puts 'saved completely-tester.sh'
|
30
|
+
complines.each_with_index do |compline, i|
|
31
|
+
show_compline compline, filename: "completely-tester-#{i + 1}.sh"
|
29
32
|
end
|
30
33
|
|
31
34
|
syntax_warning unless completions.valid?
|
@@ -33,8 +36,24 @@ module Completely
|
|
33
36
|
|
34
37
|
private
|
35
38
|
|
36
|
-
def compline
|
37
|
-
|
39
|
+
def show_compline(compline, filename: nil)
|
40
|
+
filename ||= 'completely-tester.sh'
|
41
|
+
say "!txtblu!$ !txtgrn!#{compline}!txtrst!<tab>"
|
42
|
+
puts tester.test(compline).join "\n"
|
43
|
+
puts
|
44
|
+
|
45
|
+
return unless keep
|
46
|
+
|
47
|
+
File.write filename, tester_script(compline)
|
48
|
+
say "Saved !txtpur!#{filename}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def complines
|
52
|
+
@complines ||= args['COMPLINE']
|
53
|
+
end
|
54
|
+
|
55
|
+
def keep
|
56
|
+
@keep ||= args['--keep']
|
38
57
|
end
|
39
58
|
|
40
59
|
def completions
|
@@ -45,8 +64,8 @@ module Completely
|
|
45
64
|
@tester ||= completions.tester
|
46
65
|
end
|
47
66
|
|
48
|
-
def tester_script
|
49
|
-
|
67
|
+
def tester_script(compline)
|
68
|
+
tester.tester_script compline
|
50
69
|
end
|
51
70
|
end
|
52
71
|
end
|
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.5.
|
4
|
+
version: 0.5.2
|
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-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|