• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2use builtin;
3use str;
4
5set edit:completion:arg-completer[my-app] = {|@words|
6    fn spaces {|n|
7        builtin:repeat $n ' ' | str:join ''
8    }
9    fn cand {|text desc|
10        edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
11    }
12    var command = 'my-app'
13    for word $words[1..-1] {
14        if (str:has-prefix $word '-') {
15            break
16        }
17        set command = $command';'$word
18    }
19    var completions = [
20        &'my-app'= {
21            cand -h 'Print help'
22            cand --help 'Print help'
23        }
24    ]
25    $completions[$command]
26}
27