use builtin; use str; set edit:completion:arg-completer[downtools] = {|@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 = 'downtools' for word $words[1..-1] { if (str:has-prefix $word '-') { break } set command = $command';'$word } var completions = [ &'downtools'= { 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)' } &'downtools;print-path'= { cand -s 'the source dir to find the files' cand --source-dir 'the source dir to find the files' cand -d 'the target dir to put matched files' cand --dest-dir 'the target dir to put matched files' cand -p 'the regex pattern to filter the files' cand --pattern 'the regex pattern to filter the files' cand -c 'if it is present, the pattern will be case insensitive' cand --case-insensitive 'if it is present, the pattern will be case insensitive' cand -h 'Print help information' cand --help 'Print help information' } &'downtools;move'= { cand -s 'the source dir to find the files' cand --source-dir 'the source dir to find the files' cand -d 'the target dir to put matched files' cand --dest-dir 'the target dir to put matched files' cand -p 'the regex pattern to filter the files' cand --pattern 'the regex pattern to filter the files' cand -c 'if it is present, the pattern will be case insensitive' cand --case-insensitive 'if it is present, the pattern will be case insensitive' cand -h 'Print help information' cand --help 'Print help information' } &'downtools;hlink'= { cand -s 'the source dir to find the files' cand --source-dir 'the source dir to find the files' cand -d 'the target dir to put matched files' cand --dest-dir 'the target dir to put matched files' cand -p 'the regex pattern to filter the files' cand --pattern 'the regex pattern to filter the files' cand -c 'if it is present, the pattern will be case insensitive' cand --case-insensitive 'if it is present, the pattern will be case insensitive' cand -h 'Print help information' cand --help 'Print help information' } &'downtools;copy'= { cand -s 'the source dir to find the files' cand --source-dir 'the source dir to find the files' cand -d 'the target dir to put matched files' cand --dest-dir 'the target dir to put matched files' cand -p 'the regex pattern to filter the files' cand --pattern 'the regex pattern to filter the files' cand -c 'if it is present, the pattern will be case insensitive' cand --case-insensitive 'if it is present, the pattern will be case insensitive' cand -h 'Print help information' cand --help 'Print help information' } &'downtools;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)' } &'downtools;help;print-path'= { } &'downtools;help;move'= { } &'downtools;help;hlink'= { } &'downtools;help;copy'= { } &'downtools;help;help'= { } ] $completions[$command] }