complete --help complete: complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...] Specify how arguments are to be completed by Readline.
For each NAME, specify how arguments are to be completed. If no options are supplied, existing completion specifications are printed in a way that allows them to be reused as input.
Options: -p print existing completion specifications in a reusable format -r remove a completion specification for each NAME, or, if no NAMEs are supplied, all completion specifications -D apply the completions and actions as the default for commands without any specific completion defined -E apply the completions and actions to "empty" commands -- completion attempted on a blank line
When completion is attempted, the actions are applied in the order the uppercase-letter options are listed above. The -D option takes precedence over -E.
Exit Status: Returns success unless an invalid option is supplied or an error occurs.
_bgmi() { local pre cur action local actions bangumi config actions="add delete update cal config filter fetch download list mark search source complete" config="BANGUMI_MOE_URL SAVE_PATH DOWNLOAD_DELEGATE MAX_PAGE TMP_PATH DANMAKU_API_URL" COMPREPLY=()
pre=${COMP_WORDS[COMP_CWORD-1]} cur=${COMP_WORDS[COMP_CWORD]} if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W "$actions" -- $cur ) ) else action=${COMP_WORDS[1]}
Display possible completions depending on the options.
Intended to be used from within a shell function generating possible completions. If the optional WORD argument is supplied, matches against WORD are generated.
Exit Status: Returns success unless an invalid option is supplied or an error occurs.
if [[ ${#words} -le 2 ]] then _alternative \ 'action:action options:((add\:"Subscribe bangumi." delete\:"Unsubscribe bangumi." list\:"List subscribed bangumi." filter\:"Set bangumi fetch filter." update\:"Update bangumi calendar and subscribed bangumi episode." cal\:"Print bangumi calendar." config\:"Config BGmi." mark\:"Mark bangumi episode." download\:"Download manager." fetch\:"Fetch bangumi." search\:"Search torrents from data source by keyword" source\:"Select date source bangumi_moe or mikan_project" install\:"Install BGmi front / admin / download delegate" upgrade\:"Check update." history\:"List your history of following bangumi" ))' fi
if [[ ${words[(i)cal]} -le ${#words} ]] then _alternative \ 'cal:cal options:((--today\:"Show bangumi calendar for today." -f\:"Get the newest bangumi calendar from bangumi.moe." --force-update\:"Get the newest bangumi calendar from bangumi.moe." --download-cover\:"Download the cover to local" --no-save\:"Do not save the bangumi data when force update." ))' fi
}
compdef _bgmi bgmi
#usage: eval "$(bgmi complete)" #if you are using windows, cygwin or babun, try `eval "$(bgmi complete|dos2unix)"`
因为_alternative的功能是最全的,所以我就只用了_alternative这一个命令 cal:cal options:(( -f\:"Get the newest bangumi calendar from bangumi.moe." --force-update\:"Get the newest bangumi calendar from bangumi.moe." ))
ubuntu@VM-189-243-ubuntu ~ $ bgmi cal - --download-cover -- Download the cover to local --force-update -f -- Get the newest bangumi calendar from bangumi.moe. --no-save -- Do not save the bangumi data when force update. --today -- Show bangumi calendar for today.