use builtin; use str; set edit:completion:arg-completer[tools] = {|@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 = 'tools' for word $words[1..-1] { if (str:has-prefix $word '-') { break } set command = $command';'$word } var completions = [ &'tools'= { cand -p 'The path to the directory to walk' cand --path 'The path to the directory to walk' cand -h 'Print help information' cand --help 'Print help information' cand -V 'Print version information' cand --version 'Print version information' cand print-path 'Prints the path to the directory to walk' cand move 'move the maching files to destination' cand hlink 'hardlink' cand copy 'copy' cand help 'Print this message or the help of the given subcommand(s)' } &'tools;print-path'= { cand -h 'Print help information' cand --help 'Print help information' } &'tools;move'= { cand -s 's' cand --source-dir 'source-dir' cand -d 'd' cand --dest-dir 'dest-dir' cand -p 'p' cand --pattern 'pattern' cand -h 'Print help information' cand --help 'Print help information' } &'tools;hlink'= { cand -s 's' cand --source-dir 'source-dir' cand -d 'd' cand --dest-dir 'dest-dir' cand -p 'p' cand --pattern 'pattern' cand -h 'Print help information' cand --help 'Print help information' } &'tools;copy'= { cand -s 's' cand --source-dir 'source-dir' cand -d 'd' cand --dest-dir 'dest-dir' cand -p 'p' cand --pattern 'pattern' cand -h 'Print help information' cand --help 'Print help information' } &'tools;help'= { cand print-path 'Prints the path to the directory to walk' cand move 'move the maching files to destination' cand hlink 'hardlink' cand copy 'copy' cand help 'Print this message or the help of the given subcommand(s)' } &'tools;help;print-path'= { } &'tools;help;move'= { } &'tools;help;hlink'= { } &'tools;help;copy'= { } &'tools;help;help'= { } ] $completions[$command] }