/
quoting.elvish
67 lines (65 loc) · 2.41 KB
/
quoting.elvish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use builtin;
use str;
set edit:completion:arg-completer[my-app] = {|@words|
fn spaces {|n|
builtin:repeat $n ' ' | str:join ''
}
fn cand {|text desc|
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
}
var command = 'my-app'
for word $words[1..-1] {
if (str:has-prefix $word '-') {
break
}
set command = $command';'$word
}
var completions = [
&'my-app'= {
cand --single-quotes 'Can be ''always'', ''auto'', or ''never'''
cand --double-quotes 'Can be "always", "auto", or "never"'
cand --backticks 'For more information see `echo test`'
cand --backslash 'Avoid ''/n'''
cand --brackets 'List packages [filter]'
cand --expansions 'Execute the shell command with $SHELL'
cand -h 'Print help information'
cand --help 'Print help information'
cand -V 'Print version information'
cand --version 'Print version information'
cand cmd-single-quotes 'Can be ''always'', ''auto'', or ''never'''
cand cmd-double-quotes 'Can be "always", "auto", or "never"'
cand cmd-backticks 'For more information see `echo test`'
cand cmd-backslash 'Avoid ''/n'''
cand cmd-brackets 'List packages [filter]'
cand cmd-expansions 'Execute the shell command with $SHELL'
cand help 'Print this message or the help of the given subcommand(s)'
}
&'my-app;cmd-single-quotes'= {
cand -h 'Print help information'
cand --help 'Print help information'
}
&'my-app;cmd-double-quotes'= {
cand -h 'Print help information'
cand --help 'Print help information'
}
&'my-app;cmd-backticks'= {
cand -h 'Print help information'
cand --help 'Print help information'
}
&'my-app;cmd-backslash'= {
cand -h 'Print help information'
cand --help 'Print help information'
}
&'my-app;cmd-brackets'= {
cand -h 'Print help information'
cand --help 'Print help information'
}
&'my-app;cmd-expansions'= {
cand -h 'Print help information'
cand --help 'Print help information'
}
&'my-app;help'= {
}
]
$completions[$command]
}