summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLéon Keijser <keijser@stone-it.com>2010-08-23 07:14:53 +0200
committerJesse Keating <jkeating@redhat.com>2010-08-23 14:40:22 -0700
commita8a166b98d87e796eda4fd4454bfa00a8a57ed38 (patch)
treefadc57f19713db50862b5686871cc811964b586a /src
parent6a5f791445c9ef3a779d3b836de31d83d50daedf (diff)
downloadfedora-packager-a8a166b98d87e796eda4fd4454bfa00a8a57ed38.tar.gz
fedora-packager-a8a166b98d87e796eda4fd4454bfa00a8a57ed38.tar.xz
fedora-packager-a8a166b98d87e796eda4fd4454bfa00a8a57ed38.zip
Documented bash completion script
Diffstat (limited to 'src')
-rw-r--r--src/fedpkg.bash18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/fedpkg.bash b/src/fedpkg.bash
index 8f698e8..1a29d2b 100644
--- a/src/fedpkg.bash
+++ b/src/fedpkg.bash
@@ -8,6 +8,7 @@ _fedpkg()
COMPREPLY=()
_get_comp_words_by_ref cur prev
+ # define all available commands to complete
commands='help build chain-build clean clog clone co commit ci compile \
diff gimmespec giturl import install lint local mockbuild new new-sources \
patch prep push scratch-build sources srpm switch-branch tag-request \
@@ -15,21 +16,27 @@ _fedpkg()
if [[ $COMP_CWORD -eq 1 ]] ; then
if [[ "$cur" == -* ]]; then
+ # show available options when no subcommand is provided
COMPREPLY=( $( compgen -W '-h --help -u --user --path -v -q' \
-- "$cur" ) )
else
COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
fi
else
+ # these completions are available to all commands and are executed
+ # when a specific parameter is given
case $prev in
+ # list all files in current directory
--path|--file|-F|--outdir)
_filedir
return 0;
;;
+ # list available architectures when provided with these parameters
--arch|--arches)
COMPREPLY=( $( compgen -W 'i386 i586 i686 x86_64' -- "$cur" ) )
return 0;
;;
+ # list all source RPMs in current directory
--srpm)
COMPREPLY=( ${COMPREPLY[@]:-} \
$( compgen -W '$( command ls *.src.rpm 2>/dev/null )' \
@@ -44,7 +51,7 @@ _fedpkg()
command=${COMP_WORDS[1]}
if [[ "$cur" == -* ]]; then
- # possible options for the command
+ # list possible options for the command
case $command in
build)
options='--nowait --background --skip-tag --scratch --test'
@@ -91,25 +98,30 @@ _fedpkg()
switch-branch)
options='-l'
;;
+ # don't complete by listing files in current directory for
+ # these commands, just provide the help option
clog|gimmespec|lint|mockbuild|new|giturl|push|tag-request|\
unused-patches|update|verrel)
- options='-h'
+ options='-h --help'
;;
esac
+ # these options are available to all commands
options="$options --help -h"
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
else
+ # different completion for these commands
case $command in
upload)
_filedir
;;
import)
+ # complete by listing all source rpms
COMPREPLY=( ${COMPREPLY[@]:-} \
$( compgen -W '$( command ls *.src.rpm 2>/dev/null )' \
-- "$cur" ) )
;;
- # no further args required
+ # no further arguments are required for these commands
help|build|clean|clog|compile|gimmespec|giturl|install|lint|\
local|mockbuild|new|patch|prep|push|scratch-build|sources|\
srpm|switch-branch|tag-request|unused-patches|update|verrel)