Browse Source

Add exec to autocompletions

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
Jessica Frazelle 10 years ago
parent
commit
c9c004d700
2 changed files with 23 additions and 3 deletions
  1. 16 3
      contrib/completion/bash/docker
  2. 7 0
      contrib/completion/zsh/_docker

+ 16 - 3
contrib/completion/bash/docker

@@ -244,6 +244,18 @@ _docker_events()
 	esac
 	esac
 }
 }
 
 
+_docker_exec()
+{
+	case "$cur" in
+		-*)
+			COMPREPLY=( $( compgen -W "-d --detach -i --interactive -t --tty" -- "$cur" ) )
+			;;
+		*)
+			__docker_containers_running
+			;;
+	esac
+}
+
 _docker_export()
 _docker_export()
 {
 {
 	local counter=$(__docker_pos_first_nonflag)
 	local counter=$(__docker_pos_first_nonflag)
@@ -530,7 +542,7 @@ _docker_run()
 			esac
 			esac
 			return
 			return
 			;;
 			;;
-		--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|-c|--cpu-shares|-n|--name|-p|--publish|--expose|--dns|--lxc-conf)
+		--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|--cpuset|-c|--cpu-shares|-n|--name|-p|--publish|--expose|--dns|--lxc-conf)
 			return
 			return
 			;;
 			;;
 		*)
 		*)
@@ -539,10 +551,10 @@ _docker_run()
 
 
 	case "$cur" in
 	case "$cur" in
 		-*)
 		-*)
-			COMPREPLY=( $( compgen -W "--rm -d --detach -n --networking --privileged -P --publish-all -i --interactive -t --tty --cidfile --entrypoint -h --hostname -m --memory -u --user -w --workdir -c --cpu-shares --sig-proxy --name -a --attach -v --volume --link -e --env -p --publish --expose --dns --volumes-from --lxc-conf" -- "$cur" ) )
+			COMPREPLY=( $( compgen -W "--rm -d --detach -n --networking --privileged -P --publish-all -i --interactive -t --tty --cidfile --entrypoint -h --hostname -m --memory -u --user -w --workdir --cpuset -c --cpu-shares --sig-proxy --name -a --attach -v --volume --link -e --env -p --publish --expose --dns --volumes-from --lxc-conf" -- "$cur" ) )
 			;;
 			;;
 		*)
 		*)
-			local counter=$(__docker_pos_first_nonflag '--cidfile|--volumes-from|-v|--volume|-e|--env|--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|-c|--cpu-shares|-n|--name|-a|--attach|--link|-p|--publish|--expose|--dns|--lxc-conf')
+			local counter=$(__docker_pos_first_nonflag '--cidfile|--volumes-from|-v|--volume|-e|--env|--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|--cpuset|-c|--cpu-shares|-n|--name|-a|--attach|--link|-p|--publish|--expose|--dns|--lxc-conf')
 
 
 			if [ $cword -eq $counter ]; then
 			if [ $cword -eq $counter ]; then
 				__docker_image_repos_and_tags_and_ids
 				__docker_image_repos_and_tags_and_ids
@@ -660,6 +672,7 @@ _docker()
 			cp
 			cp
 			diff
 			diff
 			events
 			events
+			exec
 			export
 			export
 			history
 			history
 			images
 			images

+ 7 - 0
contrib/completion/zsh/_docker

@@ -227,6 +227,13 @@ __docker_subcommand () {
         (diff|export)
         (diff|export)
             _arguments '*:containers:__docker_containers'
             _arguments '*:containers:__docker_containers'
             ;;
             ;;
+        (exec)
+            _arguments \
+                '-d[Detached mode: leave the container running in the background]' \
+                '-i[Keep stdin open even if not attached]' \
+                '-t[Allocate a pseudo-tty]' \
+                ':containers:__docker_runningcontainers'
+            ;;
         (history)
         (history)
             _arguments \
             _arguments \
                 '--no-trunc[Do not truncate output]' \
                 '--no-trunc[Do not truncate output]' \