# bash completions for nmh commands                        -*- shell-script -*-
# This file was generated by etc/bash_completion_nmh-gen.
#
# This code is Copyright (c) 2016, by the authors of nmh.
# See the COPYRIGHT file in the root directory of the nmh
# distribution for complete copyright information.
#
# To use:  source at a bash prompt or in an initialization file.

_nmh() {
  local -a switches

  COMPREPLY=()
  #### Complete filenames.
  compopt -o default

  case ${COMP_WORDS[COMP_CWORD]} in
  -*) case $1 in
      ali) switches=(-help -version -alias -list -nolist -user -nouser) ;;
      anno) switches=(-help -version -component -inplace -noinplace -date -nodate -draft -append -list -delete -number -preserve -nopreserve -text) ;;
      ap) switches=(-help -version -form -format -width) ;;
      burst) switches=(-help -version -inplace -noinplace -mime -nomime -automime -quiet -noquiet -verbose -noverbose) ;;
      comp) switches=(-help -version -form -use -nouse -file -draftfolder -draftmessage -nodraftfolder -editor -noedit -width -from -to -cc -fcc -subject -whatnowproc -nowhatnowproc -build) ;;
      dist) switches=(-help -version -form -annotate -noannotate -inplace -noinplace -draftfolder -draftmessage -nodraftfolder -editor -noedit -width -from -to -cc -fcc -whatnowproc -nowhatnowproc -atfile -noatfile) ;;
      dp) switches=(-help -version -form -format -width) ;;
      flist) switches=(-help -version -sequence -sequence -all -noall -showzero -noshowzero -recurse -norecurse -fast -nofast -alpha -noalpha) ;;
      flists) switches=() ;;
      flist) switches=(-help -version -sequence -sequence -all -noall -showzero -noshowzero -recurse -norecurse -fast -nofast -alpha -noalpha) ;;
      fmtdump) switches=(-help -version -form -format) ;;
      fmttest) switches=(-help -version -form -format -address -raw -date -message -file -nofile -component -dupaddrs -nodupaddrs -ccme -noccme -outsize -width -msgnum -msgcur -msgsize -unseen -dump -nodump -trace -notrace) ;;
      folder) switches=(-help -version -all -noall -create -nocreate -fast -nofast -header -noheader -recurse -norecurse -total -nototal -list -nolist -push -pop -pack -nopack -print -noprint -verbose -noverbose) ;;
      folders) switches=() ;;
      folder) switches=(-help -version -all -noall -create -nocreate -fast -nofast -header -noheader -recurse -norecurse -total -nototal -list -nolist -push -pop -pack -nopack -print -noprint -verbose -noverbose) ;;
      forw) switches=(-help -version -annotate -noannotate -form -format -noformat -filter -inplace -noinplace -mime -nomime -draftfolder -draftmessage -nodraftfolder -editor -noedit -width -from -to -cc -fcc -subject -whatnowproc -nowhatnowproc -dashstuffing -nodashstuffing -build -file -help -version -digest -issue -volume) ;;
      forw) switches=(-help -version -annotate -noannotate -form -format -noformat -filter -inplace -noinplace -mime -nomime -draftfolder -draftmessage -nodraftfolder -editor -noedit -width -from -to -cc -fcc -subject -whatnowproc -nowhatnowproc -dashstuffing -nodashstuffing -build -file -help -version -digest -issue -volume) ;;
      inc) switches=(-help -version -audit -noaudit -changecur -nochangecur -form -format -file -silent -nosilent -truncate -notruncate -width -host -port -user -proxy -sasl -nosasl -saslmech -authservice -tls -initialtls -notls -certverify -nocertverify -snoop) ;;
      install\-mh) switches=() ;;
      mark) switches=(-help -version -sequence -add -delete -list -public -nopublic -zero -nozero -empty -noempty -range -norange) ;;
      mkstemp) switches=(-help -version -directory -prefix -suffix) ;;
      mhbuild|mime) switches=(-help -version -auto -noauto -list -nolist -realsize -norealsize -headers -noheaders -directives -nodirectives -rfc934mode -norfc934mode -contentid -nocontentid -verbose -noverbose -disposition -nodisposition -headerencoding -autoheaderencoding -maxunencoded -dist) ;;
      mhfixmsg) switches=(-help -version -decodetext -decodetypes -decodeheaderfieldbodies -crlflinebreaks -nocrlflinebreaks -textcharset -notextcharset -reformat -noreformat -replacetextplain -noreplacetextplain -fixboundary -nofixboundary -fixcte -nofixcte -checkbase64 -nocheckbase64 -fixtype -outfile -rmmproc -normmproc -changecur -nochangecur -verbose -noverbose) ;;
      mhical) switches=(-help -version -form -format -reply -attendee -contenttype -infile -outfile -unfold -debug) ;;
      mhl) switches=(-help -version -bell -nobell -clear -noclear -folder -form -length -width -moreproc -nomoreproc -fmtproc -nofmtproc -help -version -file -part -type -prefer -noprefer -headers -noheaders -realsize -norealsize -changecur -nochangecur -verbose -noverbose -disposition -nodisposition -help -version -user -saslmech -authservice -browser -snoop) ;;
      mhlist) switches=(-help -version -file -part -type -prefer -noprefer -headers -noheaders -realsize -norealsize -changecur -nochangecur -verbose -noverbose -disposition -nodisposition) ;;
      mhlogin) switches=(-help -version -user -saslmech -authservice -browser -snoop) ;;
      mhmail) switches=(-help -version -to -attach -body -cc -from -headerfield -subject -resent -send -nosend) ;;
      mhmail) switches=(-help -version -to -attach -body -cc -from -headerfield -subject -resent -send -nosend) ;;
      inc) switches=(-help -version -audit -noaudit -changecur -nochangecur -form -format -file -silent -nosilent -truncate -notruncate -width -host -port -user -proxy -sasl -nosasl -saslmech -authservice -tls -initialtls -notls -certverify -nocertverify -snoop) ;;
      mhn) switches=(-help -version -file -part -type -show -noshow -list -nolist -store -nostore -headers -noheaders -realsize -norealsize -serialonly -noserialonly -form -pause -nopause -auto -noauto -rfc934mode -norfc934mode) ;;
      mhn) switches=(-help -version -file -part -type -show -noshow -list -nolist -store -nostore -headers -noheaders -realsize -norealsize -serialonly -noserialonly -form -pause -nopause -auto -noauto -rfc934mode -norfc934mode) ;;
      mhparam) switches=(-help -version -all -component -nocomponent -debug) ;;
      mhpath) switches=(-help -version) ;;
      mhshow) switches=(-help -version -file -part -type -prefer -noprefer -concat -noconcat -textonly -notextonly -inlineonly -noinlineonly -header -noheader -form -markform) ;;
      mhstore) switches=(-help -version -file -outfile -part -type -prefer -noprefer -auto -noauto -clobber -verbose -noverbose) ;;
      msgchk) switches=(-help -version -date -nodate -notify -nonotify -host -port -user -sasl -nosasl -saslmech -tls -initialtls -notls -certverify -nocertverify -authservice -snoop) ;;
      new) switches=(-help -version -mode -folders) ;;
      fnext) switches=() ;;
      new) switches=(-help -version -mode -folders) ;;
      fprev) switches=() ;;
      new) switches=(-help -version -mode -folders) ;;
      unseen) switches=() ;;
      new) switches=(-help -version -mode -folders) ;;
      next) switches=(-help -version -showproc -showmimeproc -header -noheader -checkmime -nocheckmime) ;;
      packf) switches=(-help -version -file -mbox -mmdf) ;;
      pick) switches=(-help -version -reverse -and -or -not -lbrace -component -cc -date -from -search -subject -to -after -before -datefield -sequence -nosequence -public -nopublic -zero -nozero -list -nolist -debug) ;;
      post) switches=(-help -version -alias -filter -nofilter -format -noformat -mime -nomime -msgid -nomsgid -messageid -verbose -noverbose -watch -nowatch -width -mts -sendmail -server -port -sasl -nosasl -saslmech -user -tls -initialtls -notls -snoop) ;;
      prev) switches=(-help -version -showproc -showmimeproc -header -noheader -checkmime -nocheckmime) ;;
      prompter) switches=(-help -version -erase -kill -prepend -noprepend -rapid -norapid -doteof -nodoteof) ;;
      rcvdist) switches=(-help -version -form) ;;
      rcvpack) switches=(-help -version -mbox -mmdf) ;;
      rcvstore) switches=(-help -version -create -nocreate -unseen -nounseen -zero -nozero -sequence -public -nopublic) ;;
      rcvtty) switches=(-help -version -form -format -width -bell -nobell -newline -nonewline -biff) ;;
      refile) switches=(-help -version -draft -link -nolink -preserve -nopreserve -retainsequences -noretainsequences -unlink -nounlink -src -file -rmmproc -normmproc) ;;
      repl) switches=(-help -version -annotate -noannotate -group -nogroup -cc -nocc -query -noquery -form -format -noformat -filter -inplace -noinplace -mime -nomime -fcc -width -draftfolder -draftmessage -nodraftfolder -editor -noedit -convertargs -whatnowproc -nowhatnowproc -atfile -noatfile -fmtproc -nofmtproc -build -file) ;;
      rmf) switches=(-help -version -interactive -nointeractive) ;;
      rmm) switches=(-help -version -unlink -nounlink -rmmproc -normmproc) ;;
      scan) switches=(-help -version -clear -noclear -form -format -header -noheader -width -reverse -noreverse -file) ;;
      send) switches=(-help -version -alias -draft -draftfolder -draftmessage -nodraftfolder -filter -nofilter -format -noformat -forward -noforward -mime -nomime -msgid -nomsgid -messageid -push -nopush -verbose -noverbose -watch -nowatch -mts -sendmail -server -port -sasl -nosasl -saslmech -authservice -snoop -user -tls -initialtls -notls -certverify -nocertverify -width file -help -version -compress -from) ;;
      sendfiles) switches=(-help -version -compress -from) ;;
      show) switches=(-help -version -draft -showproc -showmimeproc -header -noheader -checkmime -nocheckmime -concat -noconcat) ;;
      slocal) switches=(-help -version -addr -info -sender -user -mailbox -file -maildelivery -verbose -noverbose -suppressdup -nosuppressdup -debug) ;;
      sortm) switches=(-help -version -all -noall -datefield -textfield -notextfield -limit -nolimit -check -nocheck -verbose -noverbose) ;;
      whatnow) switches=(-help -version -draftfolder -draftmessage -nodraftfolder -editor -noedit -prompt) ;;
      whom) switches=(-help -version -alias -check -nocheck -draftfolder -draftmessage -nodraftfolder -mts -server -port -sasl -saslmech -snoop -user -tls -initialtls -notls -draft) ;;
      esac ;;

  +*) switches=($(folder -all -fast -recurse | sed 's/^/+/')) ;;

  #### Complete special message names, except after -file.  The compopt -o default above provides filename completions.  Assume that -file was fully completed, so don't need to match -fil, etc.
  [flc.np]*) [ ${COMP_CWORD:-0} -lt 2  -o  ${COMP_WORDS[$(($COMP_CWORD - 1))]} != -file ]  &&
                 switches=(first last cur . next prev) ;;
  esac

  #### Special case:  add "new" to mhpath's completions.
  [ $1 = mhpath ]  &&  switches=("${switches[*]}" + new)

  COMPREPLY=($(compgen -W "${switches[*]}" -- ${COMP_WORDS[COMP_CWORD]}))
}

complete -F _nmh ali anno ap burst comp dist dp flist flists flist fmtdump fmttest folder folders folder forw forw inc install\-mh mark mkstemp mhbuild mhfixmsg mhical mhl mhlist mhlogin mhmail mhmail inc mhn mhn mhparam mhpath mhshow mhstore msgchk new fnext new fprev new unseen new next packf pick post prev prompter rcvdist rcvpack rcvstore rcvtty refile repl rmf rmm scan send sendfiles show slocal sortm whatnow whom mime
