public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: files/misc/
Date: Mon, 19 Aug 2013 15:42:57 +0000 (UTC)	[thread overview]
Message-ID: <1376925610.d8b0e48d177a47878eeacb88f7d436d814188766.dywi@gentoo> (raw)

commit:     d8b0e48d177a47878eeacb88f7d436d814188766
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Mon Aug 19 15:20:10 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Mon Aug 19 15:20:10 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=d8b0e48d

add bash completion for roverlay-status

---
 files/misc/roverlay.bashcomp | 99 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 98 insertions(+), 1 deletion(-)

diff --git a/files/misc/roverlay.bashcomp b/files/misc/roverlay.bashcomp
index 4e6170b..49db8b4 100644
--- a/files/misc/roverlay.bashcomp
+++ b/files/misc/roverlay.bashcomp
@@ -112,5 +112,102 @@ _roverlay_comp() {
       ;;
    esac
 }
-
 complete -F _roverlay_comp roverlay
+
+_roverlay_status_comp() {
+   local cur
+   local prev
+
+   COMPREPLY=()
+   _get_comp_words_by_ref cur prev
+
+   local MODE_LONGOPTS=( '--mode' '--cli' '--html' '--cgi' )
+   local LONGOPTS=(
+      '--help' '--version'
+      '--config'
+      '--output' '--template' '--cgi-content-type' '--module-root'
+   )
+
+   local MODE_SHORTOPTS=( '-m' )
+   local SHORTOPTS=(
+      '-h' '-V' '-c' '-O' '-t' '-T' '-M'
+   )
+
+   local CMDARGS=( 'status' )
+
+   local have_mode=
+   local have_command=
+   local k
+   local first=y
+   for k in "${COMP_WORDS[@]}"; do
+      if [[ -z "${first}" ]]; then
+         case "${k}" in
+            '--cgi'|'--cli'|'--html'|'--mode'|'-m')
+               have_mode=y
+            ;;
+            *)
+               if [[ " ${CMDARGS[*]} " == *" ${k} "* ]]; then
+                  have_command=y
+               fi
+            ;;
+         esac
+
+         if [[ ( "${have_mode}" ) && ( "${have_command}" ) ]]; then
+            break
+         fi
+      else
+         first=n
+      fi
+   done
+
+   if [[ "${have_mode}" ]]; then
+      LONGOPTS+=( "${MODE_LONGOPTS[@]}" )
+      SHORTOPTS+=( "${MODE_SHORTOPTS[@]}" )
+   fi
+
+   case "${prev}" in
+      '-c'|'--config'|'-O'|'--output')
+         # options with <file> arg
+         _filedir
+      ;;
+
+      '-t'|'--template')
+         # --template accepts names and files
+         _filedir
+      ;;
+
+      '-M'|'--module-root')
+      # options with <dir> arg
+         _filedir -d
+      ;;
+
+      '-m'|'--mode')
+         COMPREPLY=( $(compgen -W "cli html cgi" -- "${cur}" ) )
+      ;;
+
+      '-T'|'--cgi-content-type')
+         # accepts any word, but text/plain, text/html are common choices
+         COMPREPLY=( $(compgen -W "text/plain text/html" -- "${cur}" ) )
+      ;;
+
+      *)
+         case "${cur}" in
+            --*)
+               COMPREPLY=( $( compgen -W "${LONGOPTS[*]}" -- "${cur}" ) )
+            ;;
+            -*)
+               COMPREPLY=(
+                  $( compgen -W "${LONGOPTS[*]} ${SHORTOPTS[*]}" -- "${cur}" )
+               )
+            ;;
+            *)
+               local words="${LONGOPTS[*]} ${SHORTOPTS[*]}"
+               [[ "${have_command}" ]] || words+=" ${CMDARGS[*]}"
+               COMPREPLY=( $( compgen -W "${words}" -- "${cur}" ) )
+            ;;
+         esac
+
+      ;;
+   esac
+}
+complete -F _roverlay_status_comp roverlay-status


             reply	other threads:[~2013-08-19 15:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19 15:42 André Erdmann [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-07-18 16:20 [gentoo-commits] proj/R_overlay:master commit in: files/misc/ André Erdmann
2014-04-01 16:38 André Erdmann
2014-02-22 15:15 André Erdmann
2013-09-23 15:30 André Erdmann
2013-09-13 16:19 André Erdmann
2013-08-09 10:18 André Erdmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376925610.d8b0e48d177a47878eeacb88f7d436d814188766.dywi@gentoo \
    --to=dywi@mailerd.de \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox