clap/clap_complete/tests/snapshots/basic.elvish
Ed Page 36bc641648 fix(help): Remove extraneous text from built-ins
This is an intermediate solution for #4408.  As there were no agreeed
upon goals, I went with what I felt read well and that I saw commonly
used on non-clap commands.

- "information" isn't really a necessary word.
- I originally favored `Print this help` but realied that doesn't read
  correctly in completions.
- Besides being shorter, the reason for the flipped short/long hint is
  it gives people the context they need for scanning, emphasizing
  "summary" and "more".

Fixes #4409
2023-01-03 11:02:26 -06:00

44 lines
1.1 KiB
Text

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 -c 'c'
cand -v 'v'
cand -h 'Print help'
cand --help 'Print help'
cand test 'Subcommand'
cand help 'Print this message or the help of the given subcommand(s)'
}
&'my-app;test'= {
cand -d 'd'
cand -c 'c'
cand -h 'Print help'
cand --help 'Print help'
}
&'my-app;help'= {
cand test 'Subcommand'
cand help 'Print this message or the help of the given subcommand(s)'
}
&'my-app;help;test'= {
}
&'my-app;help;help'= {
}
]
$completions[$command]
}