• 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 --choice 'choice'
22            cand --unknown 'unknown'
23            cand --other 'other'
24            cand -p 'p'
25            cand --path 'path'
26            cand -f 'f'
27            cand --file 'file'
28            cand -d 'd'
29            cand --dir 'dir'
30            cand -e 'e'
31            cand --exe 'exe'
32            cand --cmd-name 'cmd-name'
33            cand -c 'c'
34            cand --cmd 'cmd'
35            cand -u 'u'
36            cand --user 'user'
37            cand -H 'H'
38            cand --host 'host'
39            cand --url 'url'
40            cand --email 'email'
41            cand -h 'Print help'
42            cand --help 'Print help'
43        }
44    ]
45    $completions[$command]
46}
47