2022-03-07 20:03:46 +00:00
|
|
|
|
|
|
|
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`'
|
2022-09-02 12:35:12 +00:00
|
|
|
cand --backslash 'Avoid ''\n'''
|
2022-03-07 20:03:46 +00:00
|
|
|
cand --brackets 'List packages [filter]'
|
|
|
|
cand --expansions 'Execute the shell command with $SHELL'
|
2023-01-03 16:49:43 +00:00
|
|
|
cand -h 'Print help'
|
|
|
|
cand --help 'Print help'
|
|
|
|
cand -V 'Print version'
|
|
|
|
cand --version 'Print version'
|
2022-03-07 20:03:46 +00:00
|
|
|
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`'
|
2022-09-02 12:35:12 +00:00
|
|
|
cand cmd-backslash 'Avoid ''\n'''
|
2022-03-07 20:03:46 +00:00
|
|
|
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'= {
|
2023-01-03 16:49:43 +00:00
|
|
|
cand -h 'Print help'
|
|
|
|
cand --help 'Print help'
|
2022-03-07 20:03:46 +00:00
|
|
|
}
|
|
|
|
&'my-app;cmd-double-quotes'= {
|
2023-01-03 16:49:43 +00:00
|
|
|
cand -h 'Print help'
|
|
|
|
cand --help 'Print help'
|
2022-03-07 20:03:46 +00:00
|
|
|
}
|
|
|
|
&'my-app;cmd-backticks'= {
|
2023-01-03 16:49:43 +00:00
|
|
|
cand -h 'Print help'
|
|
|
|
cand --help 'Print help'
|
2022-03-07 20:03:46 +00:00
|
|
|
}
|
|
|
|
&'my-app;cmd-backslash'= {
|
2023-01-03 16:49:43 +00:00
|
|
|
cand -h 'Print help'
|
|
|
|
cand --help 'Print help'
|
2022-03-07 20:03:46 +00:00
|
|
|
}
|
|
|
|
&'my-app;cmd-brackets'= {
|
2023-01-03 16:49:43 +00:00
|
|
|
cand -h 'Print help'
|
|
|
|
cand --help 'Print help'
|
2022-03-07 20:03:46 +00:00
|
|
|
}
|
|
|
|
&'my-app;cmd-expansions'= {
|
2023-01-03 16:49:43 +00:00
|
|
|
cand -h 'Print help'
|
|
|
|
cand --help 'Print help'
|
2022-03-07 20:03:46 +00:00
|
|
|
}
|
|
|
|
&'my-app;help'= {
|
2022-08-25 05:44:07 +00:00
|
|
|
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`'
|
2022-09-02 12:35:12 +00:00
|
|
|
cand cmd-backslash 'Avoid ''\n'''
|
2022-08-25 05:44:07 +00:00
|
|
|
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;help;cmd-single-quotes'= {
|
|
|
|
}
|
|
|
|
&'my-app;help;cmd-double-quotes'= {
|
|
|
|
}
|
|
|
|
&'my-app;help;cmd-backticks'= {
|
|
|
|
}
|
|
|
|
&'my-app;help;cmd-backslash'= {
|
|
|
|
}
|
|
|
|
&'my-app;help;cmd-brackets'= {
|
|
|
|
}
|
|
|
|
&'my-app;help;cmd-expansions'= {
|
|
|
|
}
|
|
|
|
&'my-app;help;help'= {
|
2022-03-07 20:03:46 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
$completions[$command]
|
|
|
|
}
|