119625d8cSopenharmony_ci
219625d8cSopenharmony_ciuse builtin;
319625d8cSopenharmony_ciuse str;
419625d8cSopenharmony_ci
519625d8cSopenharmony_ciset edit:completion:arg-completer[my-app] = {|@words|
619625d8cSopenharmony_ci    fn spaces {|n|
719625d8cSopenharmony_ci        builtin:repeat $n ' ' | str:join ''
819625d8cSopenharmony_ci    }
919625d8cSopenharmony_ci    fn cand {|text desc|
1019625d8cSopenharmony_ci        edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
1119625d8cSopenharmony_ci    }
1219625d8cSopenharmony_ci    var command = 'my-app'
1319625d8cSopenharmony_ci    for word $words[1..-1] {
1419625d8cSopenharmony_ci        if (str:has-prefix $word '-') {
1519625d8cSopenharmony_ci            break
1619625d8cSopenharmony_ci        }
1719625d8cSopenharmony_ci        set command = $command';'$word
1819625d8cSopenharmony_ci    }
1919625d8cSopenharmony_ci    var completions = [
2019625d8cSopenharmony_ci        &'my-app'= {
2119625d8cSopenharmony_ci            cand --single-quotes 'Can be ''always'', ''auto'', or ''never'''
2219625d8cSopenharmony_ci            cand --double-quotes 'Can be "always", "auto", or "never"'
2319625d8cSopenharmony_ci            cand --backticks 'For more information see `echo test`'
2419625d8cSopenharmony_ci            cand --backslash 'Avoid ''\n'''
2519625d8cSopenharmony_ci            cand --brackets 'List packages [filter]'
2619625d8cSopenharmony_ci            cand --expansions 'Execute the shell command with $SHELL'
2719625d8cSopenharmony_ci            cand -h 'Print help'
2819625d8cSopenharmony_ci            cand --help 'Print help'
2919625d8cSopenharmony_ci            cand -V 'Print version'
3019625d8cSopenharmony_ci            cand --version 'Print version'
3119625d8cSopenharmony_ci            cand cmd-single-quotes 'Can be ''always'', ''auto'', or ''never'''
3219625d8cSopenharmony_ci            cand cmd-double-quotes 'Can be "always", "auto", or "never"'
3319625d8cSopenharmony_ci            cand cmd-backticks 'For more information see `echo test`'
3419625d8cSopenharmony_ci            cand cmd-backslash 'Avoid ''\n'''
3519625d8cSopenharmony_ci            cand cmd-brackets 'List packages [filter]'
3619625d8cSopenharmony_ci            cand cmd-expansions 'Execute the shell command with $SHELL'
3719625d8cSopenharmony_ci            cand help 'Print this message or the help of the given subcommand(s)'
3819625d8cSopenharmony_ci        }
3919625d8cSopenharmony_ci        &'my-app;cmd-single-quotes'= {
4019625d8cSopenharmony_ci            cand -h 'Print help'
4119625d8cSopenharmony_ci            cand --help 'Print help'
4219625d8cSopenharmony_ci        }
4319625d8cSopenharmony_ci        &'my-app;cmd-double-quotes'= {
4419625d8cSopenharmony_ci            cand -h 'Print help'
4519625d8cSopenharmony_ci            cand --help 'Print help'
4619625d8cSopenharmony_ci        }
4719625d8cSopenharmony_ci        &'my-app;cmd-backticks'= {
4819625d8cSopenharmony_ci            cand -h 'Print help'
4919625d8cSopenharmony_ci            cand --help 'Print help'
5019625d8cSopenharmony_ci        }
5119625d8cSopenharmony_ci        &'my-app;cmd-backslash'= {
5219625d8cSopenharmony_ci            cand -h 'Print help'
5319625d8cSopenharmony_ci            cand --help 'Print help'
5419625d8cSopenharmony_ci        }
5519625d8cSopenharmony_ci        &'my-app;cmd-brackets'= {
5619625d8cSopenharmony_ci            cand -h 'Print help'
5719625d8cSopenharmony_ci            cand --help 'Print help'
5819625d8cSopenharmony_ci        }
5919625d8cSopenharmony_ci        &'my-app;cmd-expansions'= {
6019625d8cSopenharmony_ci            cand -h 'Print help'
6119625d8cSopenharmony_ci            cand --help 'Print help'
6219625d8cSopenharmony_ci        }
6319625d8cSopenharmony_ci        &'my-app;help'= {
6419625d8cSopenharmony_ci            cand cmd-single-quotes 'Can be ''always'', ''auto'', or ''never'''
6519625d8cSopenharmony_ci            cand cmd-double-quotes 'Can be "always", "auto", or "never"'
6619625d8cSopenharmony_ci            cand cmd-backticks 'For more information see `echo test`'
6719625d8cSopenharmony_ci            cand cmd-backslash 'Avoid ''\n'''
6819625d8cSopenharmony_ci            cand cmd-brackets 'List packages [filter]'
6919625d8cSopenharmony_ci            cand cmd-expansions 'Execute the shell command with $SHELL'
7019625d8cSopenharmony_ci            cand help 'Print this message or the help of the given subcommand(s)'
7119625d8cSopenharmony_ci        }
7219625d8cSopenharmony_ci        &'my-app;help;cmd-single-quotes'= {
7319625d8cSopenharmony_ci        }
7419625d8cSopenharmony_ci        &'my-app;help;cmd-double-quotes'= {
7519625d8cSopenharmony_ci        }
7619625d8cSopenharmony_ci        &'my-app;help;cmd-backticks'= {
7719625d8cSopenharmony_ci        }
7819625d8cSopenharmony_ci        &'my-app;help;cmd-backslash'= {
7919625d8cSopenharmony_ci        }
8019625d8cSopenharmony_ci        &'my-app;help;cmd-brackets'= {
8119625d8cSopenharmony_ci        }
8219625d8cSopenharmony_ci        &'my-app;help;cmd-expansions'= {
8319625d8cSopenharmony_ci        }
8419625d8cSopenharmony_ci        &'my-app;help;help'= {
8519625d8cSopenharmony_ci        }
8619625d8cSopenharmony_ci    ]
8719625d8cSopenharmony_ci    $completions[$command]
8819625d8cSopenharmony_ci}
89