diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2018-07-13 13:57:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-13 13:57:04 -0400 |
commit | 827359c8e6b116b839a95460cc1775a11f84b682 (patch) | |
tree | 2c75493ec56ff9f882c766c56f128d933b0dab8b /completions | |
parent | 35b7a875fd9747a6f322e12f358aeacea778eae5 (diff) | |
parent | a04a8d1dd4d375ebe5084bac760dc82f88cfc77f (diff) | |
download | podman-827359c8e6b116b839a95460cc1775a11f84b682.tar.gz podman-827359c8e6b116b839a95460cc1775a11f84b682.tar.bz2 podman-827359c8e6b116b839a95460cc1775a11f84b682.zip |
Merge pull request #1065 from haircommander/pod-start-create-rm
Podman pod create/rm/ps commands with man pages and tests
Diffstat (limited to 'completions')
-rw-r--r-- | completions/bash/podman | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/completions/bash/podman b/completions/bash/podman index c07987a86..b01a30aaa 100644 --- a/completions/bash/podman +++ b/completions/bash/podman @@ -31,6 +31,29 @@ __podman_containers() { __podman_q ps --format "$format" "$@" } + +# __podman_pods returns a list of pods. Additional options to +# `podman pod ps` may be specified in order to filter the list, e.g. +# `__podman_containers --filter status=running` +# By default, only names are returned. +# Set PODMAN_COMPLETION_SHOW_CONTAINER_IDS=yes to also complete IDs. +# An optional first option `--id|--name` may be used to limit the +# output to the IDs or names of matching items. This setting takes +# precedence over the environment setting. +__podman_pods() { + local format + if [ "$1" = "--id" ] ; then + format='{{.ID}}' + shift + elif [ "$1" = "--name" ] ; then + format='{{.Names}}' + shift + else + format='{{.Names}}' + fi + __podman_q pod ps --format "$format" "$@" +} + # __podman_complete_containers applies completion of containers based on the current # value of `$cur` or the value of the optional first option `--cur`, if given. # Additional filters may be appended, see `__podman_containers`. @@ -43,6 +66,23 @@ __podman_complete_containers() { COMPREPLY=( $(compgen -W "$(__podman_containers "$@")" -- "$current") ) } +# __podman_complete_pods applies completion of pods based on the current +# value of `$cur` or the value of the optional first option `--cur`, if given. +# Additional filters may be appended, see `__podman_pods`. +__podman_complete_pods() { + local current="$cur" + if [ "$1" = "--cur" ] ; then + current="$2" + shift 2 + fi + COMPREPLY=( $(compgen -W "$(__podman_pods "$@")" -- "$current") ) +} + +__podman_complete_pod_names() { + local names=( $(__podman_q pod ps --format={{.Name}}) ) + COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") ) +} + __podman_complete_containers_all() { __podman_complete_containers "$@" --all } @@ -1662,10 +1702,12 @@ _podman_container_run() { esac } + _podman_create() { _podman_container_run } + _podman_run() { _podman_container_run } @@ -2013,6 +2055,105 @@ _podman_logout() { _complete_ "$options_with_args" "$boolean_options" } +_podman_pod_create() { + local options_with_args=" + --cgroup-parent + --podidfile + --label-file + --label + -l + --name + " + + local boolean_options=" + " + _complete_ "$options_with_args" "$boolean_options" +} + +__podman_pod_ps() { + local options_with_args=" + -f + --filter + --format + --sort + " + + local boolean_options=" + --cgroup + --ctr-ids + --ctr-names + --ctr-status + -q + --quiet + --no-trunc + --labels + -l + --latest + " + _complete_ "$options_with_args" "$boolean_options" +} + +_podman_pod_ls() { + __podman_pod_ps +} + +_podman_pod_list() { + __podman_pod_ps +} + +_podman_pod_ps() { + __podman_pod_ps +} + +_podman_pod_rm() { + local options_with_args=" + " + + local boolean_options=" + -a + --all + -f + --force + --latest + -l + " + _complete_ "$options_with_args" "$boolean_options" + case "$cur" in + -*) + COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) + ;; + *) + __podman_complete_pod_names + ;; + esac +} + +_podman_pod() { + local boolean_options=" + --help + -h + " + subcommands=" + create + ps + rm + " + local aliases=" + list + ls + " + __podman_subcommands "$subcommands $aliases" && return + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) + ;; + esac +} + _podman_podman() { local options_with_args=" --config -c @@ -2049,6 +2190,7 @@ _podman_podman() { logs mount pause + pod port ps pull |