From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id BD6851381F3 for ; Mon, 19 Aug 2013 15:43:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2242EE0EED; Mon, 19 Aug 2013 15:43:06 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A39F4E0EED for ; Mon, 19 Aug 2013 15:43:00 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6962F33EBA8 for ; Mon, 19 Aug 2013 15:42:59 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id EEDB9E5461 for ; Mon, 19 Aug 2013 15:42:57 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1376925610.d8b0e48d177a47878eeacb88f7d436d814188766.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: files/misc/ X-VCS-Repository: proj/R_overlay X-VCS-Files: files/misc/roverlay.bashcomp X-VCS-Directories: files/misc/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: d8b0e48d177a47878eeacb88f7d436d814188766 X-VCS-Branch: master Date: Mon, 19 Aug 2013 15:42:57 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: a64d9ba6-f9e9-4d90-80ed-45c537006fd9 X-Archives-Hash: c690e9ed021bf9f9e765bce00fcbdeab commit: d8b0e48d177a47878eeacb88f7d436d814188766 Author: André Erdmann mailerd de> AuthorDate: Mon Aug 19 15:20:10 2013 +0000 Commit: André Erdmann mailerd 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 arg + _filedir + ;; + + '-t'|'--template') + # --template accepts names and files + _filedir + ;; + + '-M'|'--module-root') + # options with 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