diff --git a/dotfiles/lib/completions/_inv b/dotfiles/lib/completions/_inv deleted file mode 100644 index 85a678a6..00000000 --- a/dotfiles/lib/completions/_inv +++ /dev/null @@ -1,2 +0,0 @@ -#compdef inv -compdef inv='invoke' \ No newline at end of file diff --git a/dotfiles/lib/completions/_invoke b/dotfiles/lib/completions/_invoke index b7e624b5..dbefa766 100644 --- a/dotfiles/lib/completions/_invoke +++ b/dotfiles/lib/completions/_invoke @@ -1,43 +1,59 @@ -#compdef invoke +#compdef inv invoke -_invoke() { - typeset -A opt_args - local context state line +typeset -A opt_args +local context state line - _arguments "*:invoke_command:->command" - - case $state in - (command) - COMMAND_COMPLETIONS=( $(_invoke_commands | tr '\n' ' ') ) - for COMPLETION in $COMMAND_COMPLETIONS - do - compadd $COMPLETION - done - ;; - esac - - return 0 -} - -function _invoke_commands() { +function _invoke_subcommands { COMMAND_COMPLETIONS=( $(invoke -l |tr -d ' ' | tail -n+2 | sed '$ d' | tr '\n' ' ') ) for COMPLETION in $COMMAND_COMPLETIONS do local comma_separated="$(echo $COMPLETION | tr -d ')\n' | tr '(' ',')" local names="$(_echo_split $comma_separated ',')" - for name in $names - do - echo $name - done + echo $names | tr '\n' ' ' done } -function _echo_split () { +function _echo_split { local IFS IFS="$2" read -rA -- arr <1 time.]" \ + "(-e --echo)"{-e,--echo}"[Echo executed commands before running.]" \ + "(-h --help)"{-h,--help}"[Show core or per-task help and exit.]:command:_invoke_subcommand" \ + "(-H --hide)"{-H,--hide}"[Set default value of run()'s 'hide' kwarg.]:command:_invoke_subcommand" \ + "(-l --list)"{-l,--list}"[List available tasks.]" \ + "(-p --pty)"{-p,--pty}"[Use a pty when executing shell commands.]" \ + "(-r --root)"{-r,--root}"[Change root directory used for finding task modules.]:directory:_directories" \ + "(-V --version)"{-V,--version}"[Show version and exit.]:" \ + "(-w --warn-only)"{-w,--warn-only}"[Warn, instead of failing, when shell commands fail.]" \ + "*:invoke command:_complete_invoke_subcommand"