#compdef inv invoke typeset -A opt_args local context state line function _invoke_subcommands { LISTINGS=( $(invoke -l | tail -n+2 | sed 's/^ *//g' | while read line ; do _remove_docstrings "$line"; done;) ) for subcommand_listing in $LISTINGS do local comma_separated="$(echo $subcommand_listing | tr -d ')\n' | tr '(' ',')" local names="$(_echo_split $comma_separated ',')" echo $names | tr '\n' ' ' done } function _remove_docstrings { local delimiter_character=' ' if echo $1 | grep ')' > /dev/null then delimiter_character=')' fi echo $1 | cut -d "$delimiter_character" -f 1 } 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"