completely 0.5.1 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/completely +1 -1
- data/lib/completely/cli.rb +1 -1
- data/lib/completely/commands/base.rb +13 -6
- data/lib/completely/commands/generate.rb +9 -4
- data/lib/completely/commands/init.rb +1 -1
- data/lib/completely/commands/test.rb +34 -15
- data/lib/completely/version.rb +1 -1
- metadata +15 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a935ee0ae2ceb0c9c7b1f579c876a97068c45f133cfeaebcc2e6a6578216af22
|
4
|
+
data.tar.gz: 624cc5668dd558f54aa8d66e6b6af765131c2f0a2442fe3c024247a52687a2fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a08c66582789427539a284b8b7e037643178cdfc602ea2621366fcd0de37bba34a6bd05a712ac5243e5538ddf19cc042549a9c6ecce1694cf8dabf5189f6e75
|
7
|
+
data.tar.gz: e654bff7e530d8cb5414a1bcefe52081542041c57387c2b71cf61d8d49f26b2b8b5df96c648b51fa83594c828f597f8f0f814e7f6760fac3cc8f5c8fb5b76aa0
|
data/bin/completely
CHANGED
data/lib/completely/cli.rb
CHANGED
@@ -10,7 +10,7 @@ module Completely
|
|
10
10
|
def self.runner
|
11
11
|
runner = MisterBin::Runner.new version: Completely::VERSION,
|
12
12
|
header: 'Completely - Bash Completions Generator',
|
13
|
-
footer: 'Run
|
13
|
+
footer: 'Run m`completely COMMAND --help` for more information'
|
14
14
|
|
15
15
|
runner.route 'init', to: Commands::Init
|
16
16
|
runner.route 'preview', to: Commands::Preview
|
@@ -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
|
|
@@ -44,8 +51,8 @@ module Completely
|
|
44
51
|
end
|
45
52
|
|
46
53
|
def syntax_warning
|
47
|
-
say! "\
|
48
|
-
say! '
|
54
|
+
say! "\nr`WARNING:`\nr`Your configuration is invalid.`"
|
55
|
+
say! 'r`All patterns must start with the same word.`'
|
49
56
|
end
|
50
57
|
end
|
51
58
|
end
|
@@ -9,20 +9,25 @@ 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
|
22
27
|
wrap = args['--wrap']
|
23
28
|
output = wrap ? wrapper_function(wrap) : script
|
24
29
|
File.write output_path, output
|
25
|
-
say "Saved
|
30
|
+
say "Saved m`#{output_path}`"
|
26
31
|
syntax_warning unless completions.valid?
|
27
32
|
end
|
28
33
|
|
@@ -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 "b`$` g`#{compline}`<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 m`#{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,43 +1,49 @@
|
|
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.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:
|
11
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.1
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '2'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.1
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
32
|
+
version: '2'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: mister_bin
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.7
|
39
|
+
version: '0.7'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.7
|
46
|
+
version: '0.7'
|
41
47
|
description: Generate bash completion scripts using simple YAML configuration
|
42
48
|
email: db@dannyben.com
|
43
49
|
executables:
|
@@ -81,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
87
|
- !ruby/object:Gem::Version
|
82
88
|
version: '0'
|
83
89
|
requirements: []
|
84
|
-
rubygems_version: 3.
|
90
|
+
rubygems_version: 3.4.5
|
85
91
|
signing_key:
|
86
92
|
specification_version: 4
|
87
93
|
summary: Bash Completions Generator
|