(buf io.StringWriter, name string)
| 402 | } |
| 403 | |
| 404 | func writePostscript(buf io.StringWriter, name string) { |
| 405 | name = strings.ReplaceAll(name, ":", "__") |
| 406 | WriteStringAndCheck(buf, fmt.Sprintf("__start_%s()\n", name)) |
| 407 | WriteStringAndCheck(buf, fmt.Sprintf(`{ |
| 408 | local cur prev words cword split |
| 409 | declare -A flaghash 2>/dev/null || : |
| 410 | declare -A aliashash 2>/dev/null || : |
| 411 | if declare -F _init_completion >/dev/null 2>&1; then |
| 412 | _init_completion -s || return |
| 413 | else |
| 414 | __%[1]s_init_completion -n "=" || return |
| 415 | fi |
| 416 | |
| 417 | local c=0 |
| 418 | local flag_parsing_disabled= |
| 419 | local flags=() |
| 420 | local two_word_flags=() |
| 421 | local local_nonpersistent_flags=() |
| 422 | local flags_with_completion=() |
| 423 | local flags_completion=() |
| 424 | local commands=("%[1]s") |
| 425 | local command_aliases=() |
| 426 | local must_have_one_flag=() |
| 427 | local must_have_one_noun=() |
| 428 | local has_completion_function="" |
| 429 | local last_command="" |
| 430 | local nouns=() |
| 431 | local noun_aliases=() |
| 432 | |
| 433 | __%[1]s_handle_word |
| 434 | } |
| 435 | |
| 436 | `, name)) |
| 437 | WriteStringAndCheck(buf, fmt.Sprintf(`if [[ $(type -t compopt) = "builtin" ]]; then |
| 438 | complete -o default -F __start_%s %s |
| 439 | else |
| 440 | complete -o default -o nospace -F __start_%s %s |
| 441 | fi |
| 442 | |
| 443 | `, name, name, name, name)) |
| 444 | WriteStringAndCheck(buf, "# ex: ts=4 sw=4 et filetype=sh\n") |
| 445 | } |
| 446 | |
| 447 | func writeCommands(buf io.StringWriter, cmd *Command) { |
| 448 | WriteStringAndCheck(buf, " commands=()\n") |
no test coverage detected