github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/completions/bash/podman (about) 1 # 2 # This bash script was originally copied and converted from the upstream 3 # github.com:docker/docker project 4 # 5 : ${PROG:=$(basename ${BASH_SOURCE})} 6 7 8 __podman_previous_extglob_setting=$(shopt -p extglob) 9 shopt -s extglob 10 11 __podman_q() { 12 podman ${host:+-H "$host"} ${config:+--config "$config"} 2>/dev/null "$@" 13 } 14 15 # __podman_containers returns a list of containers. Additional options to 16 # `podman ps` may be specified in order to filter the list, e.g. 17 # `__podman_containers --filter status=running` 18 # By default, only names are returned. 19 # Set PODMAN_COMPLETION_SHOW_CONTAINER_IDS=yes to also complete IDs. 20 # An optional first option `--id|--name` may be used to limit the 21 # output to the IDs or names of matching items. This setting takes 22 # precedence over the environment setting. 23 __podman_containers() { 24 local format 25 if [ "$1" = "--id" ] ; then 26 format='{{.ID}}' 27 shift 28 elif [ "$1" = "--name" ] ; then 29 format='{{.Names}}' 30 shift 31 elif [ "${PODMAN_COMPLETION_SHOW_CONTAINER_IDS}" = yes ] ; then 32 format='{{.ID}} {{.Names}}' 33 else 34 format='{{.Names}}' 35 fi 36 __podman_q ps --format "$format" "$@" 37 } 38 39 __podman_list_registries() { 40 sed -n -e '/registries.*=/ {s/.*\[\([^]]*\).*/\1/p;q}' /etc/containers/registries.conf | sed -e "s/[,']//g" 41 } 42 43 # __podman_pods returns a list of pods. Additional options to 44 # `podman pod ps` may be specified in order to filter the list, e.g. 45 # `__podman_containers --filter status=running` 46 # By default, only names are returned. 47 # Set PODMAN_COMPLETION_SHOW_CONTAINER_IDS=yes to also complete IDs. 48 # An optional first option `--id|--name` may be used to limit the 49 # output to the IDs or names of matching items. This setting takes 50 # precedence over the environment setting. 51 __podman_pods() { 52 local format 53 if [ "$1" = "--id" ] ; then 54 format='{{.ID}}' 55 shift 56 elif [ "$1" = "--name" ] ; then 57 format='{{.Name}}' 58 shift 59 else 60 format='{{.Name}}' 61 fi 62 __podman_q pod ps --format "$format" "$@" 63 } 64 65 # __podman_complete_containers applies completion of containers based on the current 66 # value of `$cur` or the value of the optional first option `--cur`, if given. 67 # Additional filters may be appended, see `__podman_containers`. 68 __podman_complete_containers() { 69 local current="$cur" 70 if [ "$1" = "--cur" ] ; then 71 current="$2" 72 shift 2 73 fi 74 COMPREPLY=( $(compgen -W "$(__podman_containers "$@")" -- "$current") ) 75 } 76 77 # __podman_complete_pods applies completion of pods based on the current 78 # value of `$cur` or the value of the optional first option `--cur`, if given. 79 # Additional filters may be appended, see `__podman_pods`. 80 __podman_complete_pods() { 81 local current="$cur" 82 if [ "$1" = "--cur" ] ; then 83 current="$2" 84 shift 2 85 fi 86 COMPREPLY=( $(compgen -W "$(__podman_pods "$@")" -- "$current") ) 87 } 88 89 __podman_complete_pod_names() { 90 local names=( $(__podman_q pod ps --format={{.Name}}) ) 91 COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") ) 92 } 93 94 __podman_complete_containers_all() { 95 __podman_complete_containers "$@" --all 96 } 97 98 __podman_complete_containers_created() { 99 __podman_complete_containers "$@" --all --filter status=created 100 } 101 102 __podman_complete_containers_running() { 103 __podman_complete_containers "$@" --filter status=running 104 } 105 106 __podman_complete_containers_stopped() { 107 __podman_complete_containers "$@" --all --filter status=exited 108 } 109 110 __podman_complete_containers_unpauseable() { 111 __podman_complete_containers "$@" --all --filter status=paused 112 } 113 114 __podman_complete_container_names() { 115 local containers=( $(__podman_q ps -aq --no-trunc) ) 116 local names=( $(__podman_q inspect --format '{{.Name}}' "${containers[@]}") ) 117 names=( "${names[@]#/}" ) # trim off the leading "/" from the container names 118 COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") ) 119 } 120 121 __podman_complete_container_ids() { 122 local containers=( $(__podman_q ps -aq) ) 123 COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) 124 } 125 126 __podman_images() { 127 local images_args="" 128 129 case "$PODMAN_COMPLETION_SHOW_IMAGE_IDS" in 130 all) 131 images_args="--no-trunc -a" 132 ;; 133 non-intermediate) 134 images_args="--no-trunc" 135 ;; 136 esac 137 138 local repo_print_command 139 if [ "${PODMAN_COMPLETION_SHOW_TAGS:-yes}" = "yes" ]; then 140 repo_print_command='print $1; print $1":"$2' 141 else 142 repo_print_command='print $1' 143 fi 144 145 local awk_script 146 case "$PODMAN_COMPLETION_SHOW_IMAGE_IDS" in 147 all|non-intermediate) 148 awk_script='NR>1 { print $3; if ($1 != "<none>") { '"$repo_print_command"' } }' 149 ;; 150 none|*) 151 awk_script='NR>1 && $1 != "<none>" { '"$repo_print_command"' }' 152 ;; 153 esac 154 155 __podman_q images $images_args | awk "$awk_script" | grep -v '<none>$' 156 } 157 158 __podman_complete_images() { 159 COMPREPLY=( $(compgen -W "$(__podman_images)" -- "$cur") ) 160 __ltrim_colon_completions "$cur" 161 } 162 163 __podman_complete_image_repos() { 164 local repos="$(__podman_q images | awk 'NR>1 && $1 != "<none>" { print $1 }')" 165 COMPREPLY=( $(compgen -W "$repos" -- "$cur") ) 166 } 167 168 __podman_complete_image_repos_and_tags() { 169 local reposAndTags="$(__podman_q images | awk 'NR>1 && $1 != "<none>" { print $1; print $1":"$2 }')" 170 COMPREPLY=( $(compgen -W "$reposAndTags" -- "$cur") ) 171 __ltrim_colon_completions "$cur" 172 } 173 174 # __podman_networks returns a list of all networks. Additional options to 175 # `podman network ls` may be specified in order to filter the list, e.g. 176 # `__podman_networks --filter type=custom` 177 # By default, only names are returned. 178 # Set PODMAN_COMPLETION_SHOW_NETWORK_IDS=yes to also complete IDs. 179 # An optional first option `--id|--name` may be used to limit the 180 # output to the IDs or names of matching items. This setting takes 181 # precedence over the environment setting. 182 __podman_networks() { 183 local format 184 if [ "$1" = "--id" ] ; then 185 format='{{.ID}}' 186 shift 187 elif [ "$1" = "--name" ] ; then 188 format='{{.Name}}' 189 shift 190 elif [ "${PODMAN_COMPLETION_SHOW_NETWORK_IDS}" = yes ] ; then 191 format='{{.ID}} {{.Name}}' 192 else 193 format='{{.Name}}' 194 fi 195 __podman_q network ls --format "$format" "$@" 196 } 197 198 # __podman_complete_networks applies completion of networks based on the current 199 # value of `$cur` or the value of the optional first option `--cur`, if given. 200 # Additional filters may be appended, see `__podman_networks`. 201 __podman_complete_networks() { 202 local current="$cur" 203 if [ "$1" = "--cur" ] ; then 204 current="$2" 205 shift 2 206 fi 207 COMPREPLY=( $(compgen -W "$(__podman_networks "$@")" -- "$current") ) 208 } 209 210 __podman_complete_containers_in_network() { 211 local containers=$(__podman_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1") 212 COMPREPLY=( $(compgen -W "$containers" -- "$cur") ) 213 } 214 215 __podman_runtimes() { 216 __podman_q info | sed -n 's/^Runtimes: \(.*\)/\1/p' 217 } 218 219 __podman_complete_runtimes() { 220 COMPREPLY=( $(compgen -W "$(__podman_runtimes)" -- "$cur") ) 221 } 222 223 # __podman_services returns a list of all services. Additional options to 224 # `podman service ls` may be specified in order to filter the list, e.g. 225 # `__podman_services --filter name=xxx` 226 # By default, only node names are returned. 227 # Set PODMAN_COMPLETION_SHOW_SERVICE_IDS=yes to also complete IDs. 228 # An optional first option `--id|--name` may be used to limit the 229 # output to the IDs or names of matching items. This setting takes 230 # precedence over the environment setting. 231 __podman_services() { 232 local fields='$2' # default: service name only 233 [ "${PODMAN_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && fields='$1,$2' # ID & name 234 235 if [ "$1" = "--id" ] ; then 236 fields='$1' # IDs only 237 shift 238 elif [ "$1" = "--name" ] ; then 239 fields='$2' # names only 240 shift 241 fi 242 __podman_q service ls "$@" | awk "NR>1 {print $fields}" 243 } 244 245 # __podman_complete_services applies completion of services based on the current 246 # value of `$cur` or the value of the optional first option `--cur`, if given. 247 # Additional filters may be appended, see `__podman_services`. 248 __podman_complete_services() { 249 local current="$cur" 250 if [ "$1" = "--cur" ] ; then 251 current="$2" 252 shift 2 253 fi 254 COMPREPLY=( $(compgen -W "$(__podman_services "$@")" -- "$current") ) 255 } 256 257 # __podman_append_to_completions appends the word passed as an argument to every 258 # word in `$COMPREPLY`. 259 # Normally you do this with `compgen -S` while generating the completions. 260 # This function allows you to append a suffix later. It allows you to use 261 # the __podman_complete_XXX functions in cases where you need a suffix. 262 __podman_append_to_completions() { 263 COMPREPLY=( ${COMPREPLY[@]/%/"$1"} ) 264 } 265 266 # __podman_pos_first_nonflag finds the position of the first word that is neither 267 # option nor an option's argument. If there are options that require arguments, 268 # you should pass a glob describing those options, e.g. "--option1|-o|--option2" 269 # Use this function to restrict completions to exact positions after the argument list. 270 __podman_pos_first_nonflag() { 271 local argument_flags=$1 272 273 local counter=$((${subcommand_pos:-${command_pos}} + 1)) 274 while [ $counter -le $cword ]; do 275 if [ -n "$argument_flags" ] && eval "case '${words[$counter]}' in $argument_flags) true ;; *) false ;; esac"; then 276 (( counter++ )) 277 # eat "=" in case of --option=arg syntax 278 [ "${words[$counter]}" = "=" ] && (( counter++ )) 279 else 280 case "${words[$counter]}" in 281 -*) 282 ;; 283 *) 284 break 285 ;; 286 esac 287 fi 288 289 # Bash splits words at "=", retaining "=" as a word, examples: 290 # "--debug=false" => 3 words, "--log-opt syslog-facility=daemon" => 4 words 291 while [ "${words[$counter + 1]}" = "=" ] ; do 292 counter=$(( counter + 2)) 293 done 294 295 (( counter++ )) 296 done 297 298 echo $counter 299 } 300 301 # __podman_map_key_of_current_option returns `key` if we are currently completing the 302 # value of a map option (`key=value`) which matches the extglob given as an argument. 303 # This function is needed for key-specific completions. 304 __podman_map_key_of_current_option() { 305 local glob="$1" 306 307 local key glob_pos 308 if [ "$cur" = "=" ] ; then # key= case 309 key="$prev" 310 glob_pos=$((cword - 2)) 311 elif [[ $cur == *=* ]] ; then # key=value case (OSX) 312 key=${cur%=*} 313 glob_pos=$((cword - 1)) 314 elif [ "$prev" = "=" ] ; then 315 key=${words[$cword - 2]} # key=value case 316 glob_pos=$((cword - 3)) 317 else 318 return 319 fi 320 321 [ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax 322 323 [[ ${words[$glob_pos]} == @($glob) ]] && echo "$key" 324 } 325 326 # __podman_value_of_option returns the value of the first option matching `option_glob`. 327 # Valid values for `option_glob` are option names like `--log-level` and globs like 328 # `--log-level|-l` 329 # Only positions between the command and the current word are considered. 330 __podman_value_of_option() { 331 local option_extglob=$(__podman_to_extglob "$1") 332 333 local counter=$((command_pos + 1)) 334 while [ $counter -lt $cword ]; do 335 case ${words[$counter]} in 336 $option_extglob ) 337 echo ${words[$counter + 1]} 338 break 339 ;; 340 esac 341 (( counter++ )) 342 done 343 } 344 345 # __podman_to_alternatives transforms a multiline list of strings into a single line 346 # string with the words separated by `|`. 347 # This is used to prepare arguments to __podman_pos_first_nonflag(). 348 __podman_to_alternatives() { 349 local parts=( $1 ) 350 local IFS='|' 351 echo "${parts[*]}" 352 } 353 354 # __podman_to_extglob transforms a multiline list of options into an extglob pattern 355 # suitable for use in case statements. 356 __podman_to_extglob() { 357 local extglob=$( __podman_to_alternatives "$1" ) 358 echo "@($extglob)" 359 } 360 361 # __podman_subcommands processes subcommands 362 # Locates the first occurrence of any of the subcommands contained in the 363 # first argument. In case of a match, calls the corresponding completion 364 # function and returns 0. 365 # If no match is found, 1 is returned. The calling function can then 366 # continue processing its completion. 367 # 368 # TODO if the preceding command has options that accept arguments and an 369 # argument is equal to one of the subcommands, this is falsely detected as 370 # a match. 371 __podman_subcommands() { 372 local subcommands="$1" 373 374 local counter=$(($command_pos + 1)) 375 376 while [ $counter -lt $cword ]; do 377 case "${words[$counter]}" in 378 $(__podman_to_extglob "$subcommands") ) 379 subcommand_pos=$counter 380 local subcommand=${words[$counter]} 381 local completions_func=_podman_${command}_${subcommand} 382 declare -F $completions_func >/dev/null && $completions_func 383 return 0 384 ;; 385 esac 386 (( counter++ )) 387 done 388 return 1 389 } 390 391 # __podman_nospace suppresses trailing whitespace 392 __podman_nospace() { 393 # compopt is not available in ancient bash versions 394 type compopt &>/dev/null && compopt -o nospace 395 } 396 397 __podman_complete_resolved_hostname() { 398 command -v host >/dev/null 2>&1 || return 399 COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') ) 400 } 401 402 __podman_local_interfaces() { 403 command -v ip >/dev/null 2>&1 || return 404 ip addr show scope global 2>/dev/null | sed -n 's| \+inet \([0-9.]\+\).* \([^ ]\+\)|\1 \2|p' 405 } 406 407 __podman_complete_local_interfaces() { 408 local additional_interface 409 if [ "$1" = "--add" ] ; then 410 additional_interface="$2" 411 fi 412 413 COMPREPLY=( $( compgen -W "$(__podman_local_interfaces) $additional_interface" -- "$cur" ) ) 414 } 415 416 __podman_complete_capabilities() { 417 # The list of capabilities is defined in types.go, ALL was added manually. 418 COMPREPLY=( $( compgen -W " 419 ALL 420 AUDIT_CONTROL 421 AUDIT_WRITE 422 AUDIT_READ 423 BLOCK_SUSPEND 424 CHOWN 425 DAC_OVERRIDE 426 DAC_READ_SEARCH 427 FOWNER 428 FSETID 429 IPC_LOCK 430 IPC_OWNER 431 KILL 432 LEASE 433 LINUX_IMMUTABLE 434 MAC_ADMIN 435 MAC_OVERRIDE 436 MKNOD 437 NET_ADMIN 438 NET_BIND_SERVICE 439 NET_BROADCAST 440 NET_RAW 441 SETFCAP 442 SETGID 443 SETPCAP 444 SETUID 445 SYS_ADMIN 446 SYS_BOOT 447 SYS_CHROOT 448 SYSLOG 449 SYS_MODULE 450 SYS_NICE 451 SYS_PACCT 452 SYS_PTRACE 453 SYS_RAWIO 454 SYS_RESOURCE 455 SYS_TIME 456 SYS_TTY_CONFIG 457 WAKE_ALARM 458 " -- "$cur" ) ) 459 } 460 461 __podman_complete_detach_keys() { 462 case "$prev" in 463 --detach-keys) 464 case "$cur" in 465 *,) 466 COMPREPLY=( $( compgen -W "${cur}ctrl-" -- "$cur" ) ) 467 ;; 468 *) 469 COMPREPLY=( $( compgen -W "ctrl-" -- "$cur" ) ) 470 ;; 471 esac 472 473 __podman_nospace 474 return 0 475 ;; 476 esac 477 return 1 478 } 479 480 __podman_complete_log_drivers() { 481 COMPREPLY=( $( compgen -W " 482 awslogs 483 etwlogs 484 fluentd 485 gcplogs 486 gelf 487 journald 488 json-file 489 logentries 490 none 491 splunk 492 syslog 493 k8s-file 494 " -- "$cur" ) ) 495 } 496 497 __podman_complete_log_options() { 498 # see docs/reference/logging/index.md 499 local awslogs_options="awslogs-region awslogs-group awslogs-stream" 500 local fluentd_options="env fluentd-address fluentd-async-connect fluentd-buffer-limit fluentd-retry-wait fluentd-max-retries labels tag" 501 local gcplogs_options="env gcp-log-cmd gcp-project labels" 502 local gelf_options="env gelf-address gelf-compression-level gelf-compression-type labels tag" 503 local journald_options="env labels tag" 504 local json_file_options="env labels max-file max-size" 505 local logentries_options="logentries-token" 506 local syslog_options="env labels syslog-address syslog-facility syslog-format syslog-tls-ca-cert syslog-tls-cert syslog-tls-key syslog-tls-skip-verify tag" 507 local splunk_options="env labels splunk-caname splunk-capath splunk-format splunk-gzip splunk-gzip-level splunk-index splunk-insecureskipverify splunk-source splunk-sourcetype splunk-token splunk-url splunk-verify-connection tag" 508 local k8s_file_options="env labels max-file max-size" 509 510 local all_options="$fluentd_options $gcplogs_options $gelf_options $journald_options $logentries_options $json_file_options $syslog_options $splunk_options" 511 512 case $(__podman_value_of_option --log-driver) in 513 '') 514 COMPREPLY=( $( compgen -W "$all_options" -S = -- "$cur" ) ) 515 ;; 516 awslogs) 517 COMPREPLY=( $( compgen -W "$awslogs_options" -S = -- "$cur" ) ) 518 ;; 519 fluentd) 520 COMPREPLY=( $( compgen -W "$fluentd_options" -S = -- "$cur" ) ) 521 ;; 522 gcplogs) 523 COMPREPLY=( $( compgen -W "$gcplogs_options" -S = -- "$cur" ) ) 524 ;; 525 gelf) 526 COMPREPLY=( $( compgen -W "$gelf_options" -S = -- "$cur" ) ) 527 ;; 528 journald) 529 COMPREPLY=( $( compgen -W "$journald_options" -S = -- "$cur" ) ) 530 ;; 531 json-file) 532 COMPREPLY=( $( compgen -W "$json_file_options" -S = -- "$cur" ) ) 533 ;; 534 k8s-file) 535 COMPREPLY=( $( compgen -W "$k8s_file_options" -S = -- "$cur" ) ) 536 ;; 537 logentries) 538 COMPREPLY=( $( compgen -W "$logentries_options" -S = -- "$cur" ) ) 539 ;; 540 syslog) 541 COMPREPLY=( $( compgen -W "$syslog_options" -S = -- "$cur" ) ) 542 ;; 543 splunk) 544 COMPREPLY=( $( compgen -W "$splunk_options" -S = -- "$cur" ) ) 545 ;; 546 *) 547 return 548 ;; 549 esac 550 551 __podman_nospace 552 } 553 554 __podman_complete_log_driver_options() { 555 local key=$(__podman_map_key_of_current_option '--log-opt') 556 case "$key" in 557 fluentd-async-connect) 558 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 559 return 560 ;; 561 gelf-address) 562 COMPREPLY=( $( compgen -W "udp" -S "://" -- "${cur##*=}" ) ) 563 __podman_nospace 564 return 565 ;; 566 gelf-compression-level) 567 COMPREPLY=( $( compgen -W "1 2 3 4 5 6 7 8 9" -- "${cur##*=}" ) ) 568 return 569 ;; 570 gelf-compression-type) 571 COMPREPLY=( $( compgen -W "gzip none zlib" -- "${cur##*=}" ) ) 572 return 573 ;; 574 syslog-address) 575 COMPREPLY=( $( compgen -W "tcp:// tcp+tls:// udp:// unix://" -- "${cur##*=}" ) ) 576 __podman_nospace 577 __ltrim_colon_completions "${cur}" 578 return 579 ;; 580 syslog-facility) 581 COMPREPLY=( $( compgen -W " 582 auth 583 authpriv 584 cron 585 daemon 586 ftp 587 kern 588 local0 589 local1 590 local2 591 local3 592 local4 593 local5 594 local6 595 local7 596 lpr 597 mail 598 news 599 syslog 600 user 601 uucp 602 " -- "${cur##*=}" ) ) 603 return 604 ;; 605 syslog-format) 606 COMPREPLY=( $( compgen -W "rfc3164 rfc5424 rfc5424micro" -- "${cur##*=}" ) ) 607 return 608 ;; 609 syslog-tls-ca-cert|syslog-tls-cert|syslog-tls-key) 610 _filedir 611 return 612 ;; 613 syslog-tls-skip-verify) 614 COMPREPLY=( $( compgen -W "true" -- "${cur##*=}" ) ) 615 return 616 ;; 617 splunk-url) 618 COMPREPLY=( $( compgen -W "http:// https://" -- "${cur##*=}" ) ) 619 __podman_nospace 620 __ltrim_colon_completions "${cur}" 621 return 622 ;; 623 splunk-gzip|splunk-insecureskipverify|splunk-verify-connection) 624 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 625 return 626 ;; 627 splunk-format) 628 COMPREPLY=( $( compgen -W "inline json raw" -- "${cur##*=}" ) ) 629 return 630 ;; 631 esac 632 return 1 633 } 634 635 __podman_complete_log_levels() { 636 COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) ) 637 } 638 639 # __podman_complete_signals returns a subset of the available signals that is most likely 640 # relevant in the context of podman containers 641 __podman_complete_signals() { 642 local signals=( 643 SIGCONT 644 SIGHUP 645 SIGINT 646 SIGKILL 647 SIGQUIT 648 SIGSTOP 649 SIGTERM 650 SIGUSR1 651 SIGUSR2 652 ) 653 COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) ) 654 } 655 656 __podman_complete_user_group() { 657 if [[ $cur == *:* ]] ; then 658 COMPREPLY=( $(compgen -g -- "${cur#*:}") ) 659 else 660 COMPREPLY=( $(compgen -u -S : -- "$cur") ) 661 __podman_nospace 662 fi 663 } 664 665 __podman_list_images() { 666 COMPREPLY=($(compgen -W "$(podman images -q)" -- $cur)) 667 } 668 669 __podman_list_containers() { 670 COMPREPLY=($(compgen -W "$(podman ps -aq)" -- $cur)) 671 } 672 673 __podman_images() { 674 local images_args="" 675 676 case "$PODMAN_COMPLETION_SHOW_IMAGE_IDS" in 677 all) 678 images_args="--no-trunc -a" 679 ;; 680 non-intermediate) 681 images_args="--no-trunc" 682 ;; 683 esac 684 685 local repo_print_command 686 if [ "${PODMAN_COMPLETION_SHOW_TAGS:-yes}" = "yes" ]; then 687 repo_print_command='print $1; print $1":"$2' 688 else 689 repo_print_command='print $1' 690 fi 691 692 local awk_script 693 case "$PODMAN_COMPLETION_SHOW_IMAGE_IDS" in 694 all|non-intermediate) 695 awk_script='NR>1 { print $3; if ($1 != "<none>") { '"$repo_print_command"' } }' 696 ;; 697 none|*) 698 awk_script='NR>1 && $1 != "<none>" { '"$repo_print_command"' }' 699 ;; 700 esac 701 702 __podman_q images $images_args | awk "$awk_script" | grep -v '<none>$' 703 } 704 705 # __podman_complete_volumes applies completion of volumes based on the current 706 # value of `$cur` or the value of the optional first option `--cur`, if given. 707 __podman_complete_volumes() { 708 local current="$cur" 709 if [ "$1" = "--cur" ] ; then 710 current="$2" 711 shift 2 712 fi 713 COMPREPLY=( $(compgen -W "$(__podman_volume "$@")" -- "$current") ) 714 } 715 716 __podman_complete_volume_names() { 717 local names=( $(__podman_q volume ls --quiet) ) 718 COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") ) 719 } 720 721 722 _podman_attach() { 723 local options_with_args=" 724 --detach-keys 725 " 726 local boolean_options=" 727 --help 728 -h 729 --latest 730 -l 731 --no-stdin 732 --sig-proxy 733 " 734 case "$cur" in 735 -*) 736 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 737 ;; 738 *) 739 __podman_complete_containers_running 740 ;; 741 esac 742 } 743 744 _podman_container_attach() { 745 _podman_attach 746 } 747 748 _podman_container_checkpoint() { 749 local options_with_args=" 750 -e 751 --export 752 " 753 local boolean_options=" 754 -a 755 --all 756 -h 757 --help 758 -k 759 --keep 760 -l 761 --latest 762 -R 763 --leave-running 764 --tcp-established 765 --ignore-rootfs 766 " 767 case "$prev" in 768 -e|--export) 769 _filedir 770 return 771 ;; 772 esac 773 case "$cur" in 774 -*) 775 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 776 ;; 777 *) 778 __podman_complete_containers_running 779 ;; 780 esac 781 } 782 783 _podman_container_commit() { 784 _podman_commit 785 } 786 787 _podman_container_cp() { 788 _podman_cp 789 } 790 791 _podman_container_create() { 792 _podman_create 793 } 794 795 _podman_container_diff() { 796 _podman_diff 797 } 798 799 _podman_container_exec() { 800 _podman_exec 801 } 802 803 _podman_container_export() { 804 _podman_export 805 } 806 807 _podman_container_init() { 808 _podman_init 809 } 810 811 _podman_container_inspect() { 812 _podman_inspect 813 } 814 815 _podman_container_kill() { 816 _podman_kill 817 } 818 819 _podman_container_list() { 820 _podman_ls 821 } 822 823 _podman_container_ls() { 824 _podman_ls 825 } 826 827 _podman_container_logs() { 828 _podman_logs 829 } 830 831 _podman_container_mount() { 832 _podman_mount 833 } 834 835 _podman_container_pause() { 836 _podman_pause 837 } 838 839 _podman_container_port() { 840 _podman_port 841 } 842 843 _podman_container_ps() { 844 _podman_ls 845 } 846 847 _podman_container_refresh() { 848 local options_with_args=" 849 " 850 local boolean_options=" 851 --help 852 -h 853 " 854 _complete_ "$options_with_args" "$boolean_options" 855 } 856 857 _podman_container_restart() { 858 _podman_restart 859 } 860 861 _podman_container_restore() { 862 local options_with_args=" 863 -i 864 --import 865 -n 866 --name 867 " 868 local boolean_options=" 869 -a 870 --all 871 -h 872 --help 873 -k 874 --keep 875 -l 876 --latest 877 --tcp-established 878 --ignore-rootfs 879 --ignore-static-ip 880 --ignore-static-mac 881 " 882 case "$prev" in 883 -i|--import) 884 _filedir 885 return 886 ;; 887 esac 888 case "$cur" in 889 -*) 890 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 891 ;; 892 *) 893 __podman_complete_containers_created 894 ;; 895 esac 896 } 897 898 _podman_container_rm() { 899 _podman_rm 900 } 901 902 _podman_container_start() { 903 _podman_start 904 } 905 906 _podman_container_stats() { 907 _podman_stats 908 } 909 910 _podman_container_stop() { 911 _podman_stop 912 } 913 914 _podman_container_top() { 915 _podman_top 916 } 917 918 _podman_container_umount() { 919 _podman_umount 920 } 921 922 _podman_container_unmount() { 923 _podman_unmount 924 } 925 926 _podman_container_unpause() { 927 _podman_unpause 928 } 929 930 _podman_container_wait() { 931 _podman_wait 932 } 933 934 _podman_healthcheck() { 935 local boolean_options=" 936 --help 937 -h 938 " 939 subcommands=" 940 run 941 " 942 __podman_subcommands "$subcommands $aliases" && return 943 944 case "$cur" in 945 -*) 946 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 947 ;; 948 *) 949 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 950 ;; 951 esac 952 } 953 954 _podman_network() { 955 local boolean_options=" 956 --help 957 -h 958 " 959 subcommands=" 960 create 961 inspect 962 ls 963 rm 964 " 965 __podman_subcommands "$subcommands $aliases" && return 966 967 case "$cur" in 968 -*) 969 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 970 ;; 971 *) 972 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 973 ;; 974 esac 975 } 976 977 _podman_network_create() { 978 local options_with_args=" 979 -d 980 --driver 981 --gateway 982 --ip-range 983 --macvlan 984 --subnet 985 " 986 local boolean_options=" 987 --disable-dns 988 --help 989 -h 990 --internal 991 " 992 _complete_ "$options_with_args" "$boolean_options" 993 994 case "$cur" in 995 -*) 996 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 997 ;; 998 esac 999 } 1000 _podman_network_inspect() { 1001 local options_with_args=" 1002 " 1003 local boolean_options=" 1004 --help 1005 -h 1006 " 1007 _complete_ "$options_with_args" "$boolean_options" 1008 1009 case "$cur" in 1010 -*) 1011 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1012 ;; 1013 esac 1014 } 1015 1016 _podman_network_ls() { 1017 local options_with_args=" 1018 " 1019 local boolean_options=" 1020 --help 1021 -h 1022 --quiet 1023 -q 1024 " 1025 _complete_ "$options_with_args" "$boolean_options" 1026 1027 case "$cur" in 1028 -*) 1029 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1030 ;; 1031 esac 1032 } 1033 1034 _podman_network_rm() { 1035 local options_with_args=" 1036 " 1037 local boolean_options=" 1038 --force 1039 -f 1040 --help 1041 -h 1042 " 1043 _complete_ "$options_with_args" "$boolean_options" 1044 1045 case "$cur" in 1046 -*) 1047 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1048 ;; 1049 esac 1050 } 1051 1052 _podman_generate() { 1053 local boolean_options=" 1054 --help 1055 -h 1056 " 1057 subcommands=" 1058 kube 1059 systemd 1060 " 1061 __podman_subcommands "$subcommands $aliases" && return 1062 1063 case "$cur" in 1064 -*) 1065 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1066 ;; 1067 *) 1068 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 1069 ;; 1070 esac 1071 } 1072 1073 _podman_play() { 1074 local boolean_options=" 1075 --help 1076 -h 1077 " 1078 subcommands=" 1079 kube 1080 " 1081 __podman_subcommands "$subcommands $aliases" && return 1082 1083 case "$cur" in 1084 -*) 1085 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1086 ;; 1087 *) 1088 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 1089 ;; 1090 esac 1091 } 1092 _podman_container() { 1093 local boolean_options=" 1094 --help 1095 -h 1096 " 1097 subcommands=" 1098 attach 1099 checkpoint 1100 commit 1101 cp 1102 create 1103 diff 1104 exec 1105 exists 1106 export 1107 inspect 1108 kill 1109 list 1110 logs 1111 mount 1112 pause 1113 port 1114 prune 1115 refresh 1116 restart 1117 restore 1118 rm 1119 run 1120 runlabel 1121 start 1122 stats 1123 stop 1124 top 1125 umount 1126 unmount 1127 unpause 1128 wait 1129 " 1130 local aliases=" 1131 list 1132 ps 1133 " 1134 __podman_subcommands "$subcommands $aliases" && return 1135 1136 case "$cur" in 1137 -*) 1138 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1139 ;; 1140 *) 1141 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 1142 ;; 1143 esac 1144 } 1145 1146 _podman_system_reset() { 1147 local options_with_args=" 1148 " 1149 local boolean_options=" 1150 -h 1151 --help 1152 --force 1153 " 1154 case "$cur" in 1155 -*) 1156 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1157 ;; 1158 esac 1159 } 1160 1161 _podman_system_df() { 1162 local options_with_args=" 1163 --format 1164 --verbose 1165 " 1166 local boolean_options=" 1167 -h 1168 --help 1169 --verbose 1170 -v 1171 " 1172 case "$cur" in 1173 -*) 1174 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1175 ;; 1176 esac 1177 } 1178 1179 _podman_system_info() { 1180 _podman_info 1181 } 1182 1183 _podman_system_prune() { 1184 local options_with_args=" 1185 " 1186 1187 local boolean_options=" 1188 -a 1189 --all 1190 -f 1191 --force 1192 -h 1193 --help 1194 --volumes 1195 " 1196 case "$cur" in 1197 -*) 1198 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1199 ;; 1200 esac 1201 } 1202 1203 _podman_system_service() { 1204 local options_with_args=" 1205 -t 1206 --timeout 1207 " 1208 local boolean_options=" 1209 --help 1210 -h 1211 --varlink 1212 " 1213 _complete_ "$options_with_args" "$boolean_options" 1214 } 1215 1216 _podman_system() { 1217 local boolean_options=" 1218 --help 1219 -h 1220 " 1221 subcommands=" 1222 df 1223 info 1224 migrate 1225 prune 1226 renumber 1227 reset 1228 service 1229 " 1230 __podman_subcommands "$subcommands" && return 1231 1232 case "$cur" in 1233 -*) 1234 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1235 ;; 1236 *) 1237 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 1238 ;; 1239 esac 1240 } 1241 1242 _podman_commit() { 1243 local options_with_args=" 1244 --author 1245 -a 1246 --change 1247 -c 1248 --message 1249 -m 1250 --iidfile 1251 " 1252 local boolean_options=" 1253 --help 1254 -h 1255 --pause 1256 -p 1257 --quiet 1258 -q 1259 " 1260 _complete_ "$options_with_args" "$boolean_options" 1261 1262 case "$cur" in 1263 -*) 1264 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1265 ;; 1266 *) 1267 __podman_complete_container_names 1268 ;; 1269 esac 1270 } 1271 1272 _podman_build() { 1273 local boolean_options=" 1274 --force-rm 1275 --help 1276 -h 1277 --layers 1278 --no-cache 1279 --pull 1280 --pull-always 1281 --pull-never 1282 --quiet 1283 -q 1284 --rm 1285 --squash 1286 --squash-all 1287 --tls-verify 1288 " 1289 1290 local options_with_args=" 1291 --add-host 1292 --annotation 1293 --authfile 1294 --build-arg 1295 --cap-add 1296 --cap-drop 1297 --cgroup-parent 1298 --cni-config-dir 1299 --cni-plugin-path 1300 --cpu-period 1301 --cpu-quota 1302 --cpu-shares 1303 --cpuset-cpus 1304 --cpuset-mems 1305 --creds 1306 -f 1307 --file 1308 --format 1309 --iidfile 1310 --ipc 1311 --label 1312 -m 1313 --memory 1314 --memory-swap 1315 --net 1316 --network 1317 --pid 1318 --runtime-flag 1319 --security-opt 1320 --shm-size 1321 -t 1322 --tag 1323 --ulimit 1324 --userns 1325 --userns-uid-map 1326 --userns-gid-map 1327 --userns-uid-map-user 1328 --userns-gid-map-group 1329 --uts 1330 --mount 1331 --volume 1332 -v 1333 " 1334 1335 case "$prev" in 1336 --file|-f) 1337 COMPREPLY=($(compgen -W "`ls`" -- "$cur")) 1338 ;; 1339 esac 1340 1341 case "$cur" in 1342 -*) 1343 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1344 ;; 1345 esac 1346 } 1347 1348 _podman_diff() { 1349 local options_with_args=" 1350 --format 1351 " 1352 local boolean_options=" 1353 --help 1354 -h 1355 " 1356 _complete_ "$options_with_args" "$boolean_options" 1357 1358 case "$cur" in 1359 -*) 1360 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1361 ;; 1362 *) 1363 __podman_complete_container_names 1364 ;; 1365 esac 1366 } 1367 1368 _podman_exec() { 1369 local options_with_args=" 1370 --detach-keys 1371 -e 1372 --env 1373 --env-file 1374 --user 1375 -u 1376 --workdir 1377 -w 1378 " 1379 local boolean_options=" 1380 --help 1381 -h 1382 --latest 1383 -l 1384 --privileged 1385 --tty 1386 -t 1387 " 1388 case "$cur" in 1389 -*) 1390 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1391 ;; 1392 *) 1393 __podman_complete_containers_running 1394 ;; 1395 esac 1396 1397 } 1398 _podman_export() { 1399 local options_with_args=" 1400 --output 1401 -o 1402 " 1403 local boolean_options=" 1404 --help 1405 -h 1406 " 1407 case "$cur" in 1408 -*) 1409 COMPREPLY=($(compgen -W "$options_with_args" -- "$cur")) 1410 ;; 1411 *) 1412 __podman_complete_container_names 1413 ;; 1414 esac 1415 } 1416 1417 _podman_history() { 1418 local options_with_args=" 1419 --format 1420 " 1421 local boolean_options=" 1422 --help 1423 -h 1424 --human -H 1425 --no-trunc 1426 --quiet -q 1427 " 1428 _complete_ "$options_with_args" "$boolean_options" 1429 1430 case "$cur" in 1431 -*) 1432 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1433 ;; 1434 *) 1435 __podman_complete_images --id 1436 ;; 1437 esac 1438 } 1439 1440 1441 _podman_import() { 1442 local options_with_args=" 1443 --change 1444 -c 1445 --message 1446 -m 1447 " 1448 local boolean_options=" 1449 --help 1450 -h 1451 --quiet 1452 -q 1453 " 1454 case "$prev" in 1455 --change|-c|--message|-m) 1456 return 1457 ;; 1458 esac 1459 1460 case "$cur" in 1461 -*) 1462 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1463 ;; 1464 *) 1465 local counter=$(__podman_pos_first_nonflag '--change|-c|--message|-m') 1466 if [ "$cword" -eq "$counter" ]; then 1467 _filedir 1468 return 1469 elif [ "$cword" -eq "$((counter + 1))" ]; then 1470 __podman_complete_images --repo --tag 1471 return 1472 fi 1473 ;; 1474 esac 1475 } 1476 1477 _podman_info() { 1478 local boolean_options=" 1479 --help 1480 -h 1481 --debug 1482 " 1483 local options_with_args=" 1484 -f 1485 --format 1486 " 1487 1488 local all_options="$options_with_args $boolean_options" 1489 1490 case "$cur" in 1491 -*) 1492 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1493 ;; 1494 *) 1495 __podman_list_images 1496 ;; 1497 esac 1498 } 1499 1500 _podman_image_build() { 1501 _podman_build 1502 } 1503 1504 _podman_image_history() { 1505 _podman_history 1506 } 1507 1508 _podman_image_import() { 1509 _podman_import 1510 } 1511 1512 _podman_image_inspect() { 1513 _podman_inspect 1514 } 1515 1516 _podman_image_load() { 1517 _podman_load 1518 } 1519 1520 _podman_image_list() { 1521 _podman_images 1522 } 1523 1524 _podman_image_ls() { 1525 _podman_images 1526 } 1527 1528 _podman_image_pull() { 1529 _podman_pull 1530 } 1531 1532 _podman_image_push() { 1533 _podman_push 1534 } 1535 1536 _podman_image_rm() { 1537 _podman_rmi 1538 } 1539 1540 _podman_image_save() { 1541 _podman_save 1542 } 1543 1544 _podman_image_tag() { 1545 _podman_tag 1546 } 1547 1548 _podman_image() { 1549 local boolean_options=" 1550 --help 1551 -h 1552 " 1553 subcommands=" 1554 build 1555 exists 1556 history 1557 import 1558 inspect 1559 load 1560 ls 1561 prune 1562 pull 1563 push 1564 rm 1565 save 1566 sign 1567 tag 1568 trust 1569 " 1570 local aliases=" 1571 list 1572 " 1573 __podman_subcommands "$subcommands $aliases" && return 1574 1575 case "$cur" in 1576 -*) 1577 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1578 ;; 1579 *) 1580 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 1581 ;; 1582 esac 1583 } 1584 1585 _podman_images() { 1586 local boolean_options=" 1587 -a 1588 --all 1589 --digests 1590 --digests 1591 -f 1592 --filter 1593 -h 1594 --help 1595 --history 1596 --no-trunc 1597 --notruncate 1598 -n 1599 --noheading 1600 -q 1601 --quiet 1602 " 1603 local options_with_args=" 1604 --format 1605 --sort 1606 " 1607 1608 local all_options="$options_with_args $boolean_options" 1609 1610 case "$cur" in 1611 -*) 1612 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1613 ;; 1614 *) 1615 __podman_complete_images --id 1616 ;; 1617 esac 1618 } 1619 1620 _podman_inspect() { 1621 local boolean_options=" 1622 --help 1623 -h 1624 --latest 1625 -l 1626 " 1627 local options_with_args=" 1628 --format 1629 -f 1630 --type 1631 -t 1632 --size 1633 -s 1634 " 1635 1636 local all_options="$options_with_args $boolean_options" 1637 1638 local preselected_type 1639 local type 1640 1641 if [ "$1" = "--type" ] ; then 1642 preselected_type=yes 1643 type="$2" 1644 else 1645 type=$(__podman_value_of_option --type) 1646 fi 1647 1648 case "$prev" in 1649 --format|-f) 1650 return 1651 ;; 1652 --type) 1653 if [ -z "$preselected_type" ] ; then 1654 COMPREPLY=( $( compgen -W "container image" -- "$cur" ) ) 1655 return 1656 fi 1657 ;; 1658 esac 1659 1660 case "$cur" in 1661 -*) 1662 local options="--format -f --help --size -s" 1663 if [ -z "$preselected_type" ] ; then 1664 options+=" --type" 1665 fi 1666 COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) 1667 ;; 1668 *) 1669 case "$type" in 1670 '') 1671 COMPREPLY=( $( compgen -W " 1672 $(__podman_containers --all) 1673 $(__podman_images --force-tag --id) 1674 " -- "$cur" ) ) 1675 __ltrim_colon_completions "$cur" 1676 ;; 1677 container) 1678 __podman_complete_containers_all 1679 ;; 1680 image) 1681 __podman_complete_images --force-tag --id 1682 ;; 1683 esac 1684 esac 1685 } 1686 1687 _podman_kill() { 1688 local options_with_args=" 1689 --signal -s 1690 " 1691 local boolean_options=" 1692 --all 1693 -a 1694 --help 1695 -h 1696 --latest 1697 -l 1698 " 1699 case "$cur" in 1700 -*) 1701 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1702 ;; 1703 *) 1704 __podman_complete_containers_running 1705 ;; 1706 esac 1707 } 1708 1709 _podman_logs() { 1710 local options_with_args=" 1711 --since 1712 --tail 1713 " 1714 local boolean_options=" 1715 --follow 1716 -f 1717 --help 1718 -h 1719 --latest 1720 -l 1721 --timestamps 1722 -t 1723 " 1724 _complete_ "$options_with_args" "$boolean_options" 1725 1726 case "$cur" in 1727 -*) 1728 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1729 ;; 1730 *) 1731 __podman_list_containers 1732 ;; 1733 esac 1734 } 1735 1736 _podman_pull() { 1737 local options_with_args=" 1738 --authfile 1739 --creds 1740 --cert-dir 1741 " 1742 local boolean_options=" 1743 --all-tags 1744 -a 1745 --help 1746 -h 1747 --quiet 1748 -q 1749 --tls-verify 1750 " 1751 _complete_ "$options_with_args" "$boolean_options" 1752 } 1753 1754 _podman_search() { 1755 local options_with_args=" 1756 --authfile 1757 --filter -f 1758 --format 1759 --limit 1760 " 1761 local boolean_options=" 1762 --help 1763 -h 1764 --no-trunc 1765 " 1766 _complete_ "$options_with_args" "$boolean_options" 1767 } 1768 1769 _podman_unmount() { 1770 _podman_umount $@ 1771 } 1772 1773 _podman_umount() { 1774 local boolean_options=" 1775 --all 1776 -a 1777 --help 1778 -h 1779 --force 1780 -f 1781 --latest 1782 -l 1783 " 1784 local options_with_args=" 1785 " 1786 1787 local all_options="$options_with_args $boolean_options" 1788 case "$cur" in 1789 -*) 1790 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1791 ;; 1792 *) 1793 __podman_complete_container_names 1794 ;; 1795 esac 1796 } 1797 1798 _podman_mount() { 1799 local boolean_options=" 1800 --all 1801 -a 1802 --help 1803 -h 1804 -l 1805 --latest 1806 --notruncate 1807 " 1808 1809 local options_with_args=" 1810 --format 1811 " 1812 1813 local all_options="$options_with_args $boolean_options" 1814 case "$cur" in 1815 -*) 1816 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1817 ;; 1818 *) 1819 __podman_complete_container_names 1820 ;; 1821 esac 1822 } 1823 1824 _podman_push() { 1825 local boolean_options=" 1826 --compress 1827 --digestflag 1828 --help 1829 -h 1830 --quiet 1831 -q 1832 --tls-verify 1833 " 1834 1835 local options_with_args=" 1836 --authfile 1837 --format 1838 --cert-dir 1839 --creds 1840 --sign-by 1841 " 1842 1843 local all_options="$options_with_args $boolean_options" 1844 1845 case "$cur" in 1846 -*) 1847 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1848 ;; 1849 *) 1850 __podman_complete_images --id 1851 ;; 1852 esac 1853 } 1854 1855 _podman_container_run() { 1856 local options_with_args=" 1857 --add-host 1858 --annotation 1859 --attach -a 1860 --blkio-weight 1861 --blkio-weight-device 1862 --builtin-volume 1863 --cap-add 1864 --cap-drop 1865 --cgroup-parent 1866 --cidfile 1867 --conmon-pidfile 1868 --cpu-period 1869 --cpu-quota 1870 --cpu-rt-period 1871 --cpu-rt-runtime 1872 --cpuset-cpus 1873 --cpus 1874 --cpuset-mems 1875 --cpu-shares -c 1876 --device 1877 --device-cgroup-rule 1878 --device-read-bps 1879 --device-read-iops 1880 --device-write-bps 1881 --device-write-iops 1882 --dns 1883 --dns-option 1884 --dns-search 1885 --entrypoint 1886 --env -e 1887 --env-host 1888 --env-file 1889 --expose 1890 --gidmap 1891 --group-add 1892 --health-cmd 1893 --health-interval 1894 --health-retries 1895 --health-start-period 1896 --health-timeout 1897 --hostname -h 1898 --http-proxy 1899 --image-volume 1900 --init-path 1901 --ip 1902 --ipc 1903 --kernel-memory 1904 --label-file 1905 --label -l 1906 --log-driver 1907 --log-opt 1908 --mac-address 1909 --memory -m 1910 --memory-swap 1911 --memory-swappiness 1912 --memory-reservation 1913 --name 1914 --network 1915 --no-healthcheck 1916 --no-hosts 1917 --oom-score-adj 1918 --pid 1919 --pids-limit 1920 --pod 1921 --publish -p 1922 --pull 1923 --runtime 1924 --rootfs 1925 --security-opt 1926 --shm-size 1927 --stop-signal 1928 --stop-timeout 1929 --tmpfs 1930 --subgidname 1931 --subuidname 1932 --sysctl 1933 --systemd 1934 --uidmap 1935 --ulimit 1936 --user -u 1937 --userns 1938 --uts 1939 --volumes-from 1940 --volume -v 1941 --workdir -w 1942 " 1943 1944 local boolean_options=" 1945 --disable-content-trust=false 1946 --help 1947 -h 1948 --init 1949 --interactive -i 1950 --oom-kill-disable 1951 --privileged 1952 --publish-all -P 1953 --quiet 1954 --read-only 1955 --read-only-tmpfs 1956 --tty -t 1957 " 1958 1959 if [ "$command" = "run" -o "$subcommand" = "run" ] ; then 1960 options_with_args="$options_with_args 1961 --detach-keys 1962 --health-cmd 1963 --health-interval 1964 --health-retries 1965 --health-timeout 1966 --health-start-period 1967 " 1968 boolean_options="$boolean_options 1969 --detach -d 1970 --rm 1971 --rmi 1972 --sig-proxy=false 1973 " 1974 __podman_complete_detach_keys && return 1975 fi 1976 1977 case "$cur" in 1978 -*) 1979 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 1980 return 1981 ;; 1982 *) 1983 __podman_complete_images --id 1984 ;; 1985 esac 1986 1987 1988 __podman_complete_log_driver_options && return 1989 1990 local key=$(__podman_map_key_of_current_option '--security-opt') 1991 case "$key" in 1992 label) 1993 [[ $cur == *: ]] && return 1994 COMPREPLY=( $( compgen -W "user: role: type: level: disable" -- "${cur##*=}") ) 1995 if [ "${COMPREPLY[*]}" != "disable" ] ; then 1996 __podman_nospace 1997 fi 1998 return 1999 ;; 2000 seccomp) 2001 local cur=${cur##*=} 2002 _filedir 2003 COMPREPLY+=( $( compgen -W "unconfined" -- "$cur" ) ) 2004 return 2005 ;; 2006 esac 2007 2008 case "$prev" in 2009 --add-host) 2010 case "$cur" in 2011 *:) 2012 __podman_complete_resolved_hostname 2013 return 2014 ;; 2015 esac 2016 ;; 2017 --attach|-a) 2018 COMPREPLY=( $( compgen -W 'stdin stdout stderr' -- "$cur" ) ) 2019 return 2020 ;; 2021 --cap-add|--cap-drop) 2022 __podman_complete_capabilities 2023 return 2024 ;; 2025 --cidfile|--env-file|--init-path|--label-file) 2026 _filedir 2027 return 2028 ;; 2029 --device|--tmpfs|--volume|-v) 2030 case "$cur" in 2031 *:*) 2032 # TODO somehow do _filedir for stuff inside the image, if it's already specified (which is also somewhat difficult to determine) 2033 ;; 2034 '') 2035 COMPREPLY=( $( compgen -W '/' -- "$cur" ) ) 2036 __podman_nospace 2037 ;; 2038 /*) 2039 _filedir 2040 __podman_nospace 2041 ;; 2042 esac 2043 return 2044 ;; 2045 --env|-e) 2046 # we do not append a "=" here because "-e VARNAME" is legal syntax, too 2047 COMPREPLY=( $( compgen -e -- "$cur" ) ) 2048 __podman_nospace 2049 return 2050 ;; 2051 --ipc) 2052 case "$cur" in 2053 *:*) 2054 cur="${cur#*:}" 2055 __podman_complete_containers_running 2056 ;; 2057 *) 2058 COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) ) 2059 if [ "$COMPREPLY" = "container:" ]; then 2060 __podman_nospace 2061 fi 2062 ;; 2063 esac 2064 return 2065 ;; 2066 --log-driver) 2067 __podman_complete_log_drivers 2068 return 2069 ;; 2070 --log-opt) 2071 __podman_complete_log_options 2072 return 2073 ;; 2074 --network) 2075 case "$cur" in 2076 container:*) 2077 __podman_complete_containers_all --cur "${cur#*:}" 2078 ;; 2079 *) 2080 COMPREPLY=( $( compgen -W "$(__podman_plugins_bundled --type Network) $(__podman_networks) container:" -- "$cur") ) 2081 if [ "${COMPREPLY[*]}" = "container:" ] ; then 2082 __podman_nospace 2083 fi 2084 ;; 2085 esac 2086 return 2087 ;; 2088 --pod) 2089 __podman_complete_pod_names 2090 return 2091 ;; 2092 --pid) 2093 case "$cur" in 2094 *:*) 2095 __podman_complete_containers_running --cur "${cur#*:}" 2096 ;; 2097 *) 2098 COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) ) 2099 if [ "$COMPREPLY" = "container:" ]; then 2100 __podman_nospace 2101 fi 2102 ;; 2103 esac 2104 return 2105 ;; 2106 --runtime) 2107 __podman_complete_runtimes 2108 return 2109 ;; 2110 --security-opt) 2111 COMPREPLY=( $( compgen -W "apparmor= label= no-new-privileges seccomp=" -- "$cur") ) 2112 if [ "${COMPREPLY[*]}" != "no-new-privileges" ] ; then 2113 __podman_nospace 2114 fi 2115 return 2116 ;; 2117 --storage-opt) 2118 COMPREPLY=( $( compgen -W "size" -S = -- "$cur") ) 2119 __podman_nospace 2120 return 2121 ;; 2122 --user|-u) 2123 __podman_complete_user_group 2124 return 2125 ;; 2126 --userns) 2127 COMPREPLY=( $( compgen -W "host" -- "$cur" ) ) 2128 return 2129 ;; 2130 --volumes-from) 2131 __podman_complete_containers_all 2132 return 2133 ;; 2134 $(__podman_to_extglob "$options_with_args") ) 2135 return 2136 ;; 2137 esac 2138 2139 case "$cur" in 2140 -*) 2141 COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) 2142 ;; 2143 *) 2144 local counter=$( __podman_pos_first_nonflag $( __podman_to_alternatives "$options_with_args" ) ) 2145 if [ $cword -eq $counter ]; then 2146 __podman_complete_images 2147 fi 2148 ;; 2149 esac 2150 } 2151 2152 2153 _podman_create() { 2154 _podman_container_run 2155 } 2156 2157 2158 _podman_run() { 2159 _podman_container_run 2160 } 2161 2162 _podman_restart() { 2163 local options_with_args=" 2164 --time -t 2165 " 2166 local boolean_options=" 2167 --all 2168 -a 2169 --help 2170 -h 2171 --latest 2172 -l 2173 --running 2174 " 2175 case "$cur" in 2176 -*) 2177 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2178 ;; 2179 *) 2180 __podman_complete_containers_running 2181 ;; 2182 esac 2183 } 2184 2185 _podman_rm() { 2186 local boolean_options=" 2187 --all 2188 -a 2189 --cidfile 2190 --force 2191 -f 2192 --help 2193 -h 2194 --ignore 2195 -i 2196 --latest 2197 -l 2198 --storage 2199 --volumes 2200 -v 2201 " 2202 2203 local options_with_args=" 2204 " 2205 2206 local all_options="$options_with_args $boolean_options" 2207 2208 case "$cur" in 2209 -*) 2210 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2211 ;; 2212 *) 2213 __podman_complete_container_names 2214 ;; 2215 esac 2216 } 2217 2218 _podman_rmi() { 2219 local boolean_options=" 2220 --all 2221 -a 2222 --force 2223 -f 2224 --help 2225 -h 2226 " 2227 2228 case "$cur" in 2229 -*) 2230 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2231 ;; 2232 *) 2233 __podman_complete_images --id 2234 ;; 2235 esac 2236 } 2237 2238 _podman_stats() { 2239 local boolean_options=" 2240 --all 2241 -a 2242 --help 2243 -h 2244 --no-stream 2245 --format 2246 --no-reset 2247 " 2248 2249 case "$cur" in 2250 -*) 2251 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2252 ;; 2253 *) 2254 __podman_complete_containers_running 2255 ;; 2256 esac 2257 } 2258 2259 _podman_tag() { 2260 local options_with_args=" 2261 " 2262 local boolean_options=" 2263 --help 2264 -h 2265 " 2266 case "$cur" in 2267 -*) 2268 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2269 ;; 2270 *) 2271 __podman_complete_images 2272 ;; 2273 esac 2274 } 2275 2276 __podman_top_descriptors() { 2277 podman top --list-descriptors 2278 } 2279 2280 __podman_complete_top_descriptors() { 2281 COMPREPLY=($(compgen -W "$(__podman_top_descriptors)" -- "$cur")) 2282 } 2283 2284 _podman_top() { 2285 local options_with_args=" 2286 " 2287 local boolean_options=" 2288 --help 2289 -h 2290 --latest 2291 -l 2292 " 2293 2294 # podman-top works on only *one* container, which means that when we have 2295 # three or more arguments, we can complete with top descriptors. 2296 if [[ "${COMP_CWORD}" -ge 3 ]]; then 2297 __podman_complete_top_descriptors 2298 return 2299 fi 2300 2301 case "$cur" in 2302 -*) 2303 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2304 ;; 2305 *) 2306 __podman_complete_containers_running 2307 ;; 2308 esac 2309 } 2310 2311 _podman_version() { 2312 local boolean_options=" 2313 --help 2314 -h 2315 " 2316 local options_with_args=" 2317 --format 2318 -f 2319 " 2320 local all_options="$options_with_args $boolean_options" 2321 2322 _complete_ "$options_with_args" "$boolean_options" 2323 } 2324 2325 _podman_save() { 2326 local options_with_args=" 2327 --output -o 2328 --format 2329 " 2330 local boolean_options=" 2331 --compress 2332 --help 2333 -h 2334 -q 2335 --quiet 2336 " 2337 2338 case "$cur" in 2339 -*) 2340 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2341 ;; 2342 *) 2343 __podman_complete_images --id 2344 ;; 2345 esac 2346 } 2347 2348 _podman_pause() { 2349 local boolean_options=" 2350 --all 2351 -a 2352 --help 2353 -h 2354 " 2355 local options_with_args=" 2356 " 2357 local boolean_options="" 2358 case "$cur" in 2359 -*) 2360 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2361 ;; 2362 *) 2363 __podman_complete_containers_running 2364 ;; 2365 esac 2366 } 2367 2368 _podman_port() { 2369 local options_with_args=" 2370 " 2371 local boolean_options=" 2372 --all 2373 -a 2374 --help 2375 -h 2376 -l 2377 --latest 2378 " 2379 case "$cur" in 2380 -*) 2381 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2382 ;; 2383 *) 2384 __podman_complete_container_names 2385 ;; 2386 esac 2387 } 2388 2389 _podman_ls() { 2390 _podman_ps 2391 } 2392 2393 _podman_ps() { 2394 local options_with_args=" 2395 --filter -f 2396 --format 2397 --last -n 2398 --sort 2399 --watch -w 2400 " 2401 local boolean_options=" 2402 --all -a 2403 --help -h 2404 --latest -l 2405 --no-trunc 2406 --pod -p 2407 --quiet -q 2408 --size -s 2409 --namespace --ns 2410 --sync 2411 " 2412 _complete_ "$options_with_args" "$boolean_options" 2413 } 2414 2415 _podman_init() { 2416 local boolean_options=" 2417 --all 2418 -a 2419 --help 2420 -h 2421 --latest 2422 -l 2423 " 2424 local options_with_args=" 2425 " 2426 case "$cur" in 2427 -*) 2428 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2429 ;; 2430 *) 2431 __podman_complete_containers_unpauseable 2432 ;; 2433 esac 2434 } 2435 2436 _podman_start() { 2437 local options_with_args=" 2438 --detach-keys 2439 " 2440 2441 local boolean_options=" 2442 --attach 2443 -a 2444 -h 2445 --help 2446 -i 2447 --interactive 2448 --latest 2449 -l 2450 --sig-proxy 2451 " 2452 case "$cur" in 2453 -*) 2454 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2455 ;; 2456 *) 2457 __podman_complete_containers_stopped 2458 ;; 2459 esac 2460 } 2461 _podman_stop() { 2462 local options_with_args=" 2463 --time -t 2464 " 2465 local boolean_options=" 2466 --all 2467 -a 2468 --cidfile 2469 -h 2470 --help 2471 --ignore 2472 -i 2473 --latest 2474 -l 2475 " 2476 case "$cur" in 2477 -*) 2478 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2479 ;; 2480 *) 2481 __podman_complete_containers_running 2482 ;; 2483 esac 2484 } 2485 2486 _podman_unpause() { 2487 local boolean_options=" 2488 --all 2489 -a 2490 --help 2491 -h 2492 " 2493 local options_with_args=" 2494 " 2495 case "$cur" in 2496 -*) 2497 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2498 ;; 2499 *) 2500 __podman_complete_containers_unpauseable 2501 ;; 2502 esac 2503 } 2504 2505 _podman_varlink() { 2506 local options_with_args=" 2507 --timeout -t 2508 " 2509 local boolean_options=" 2510 --help 2511 -h 2512 " 2513 _complete_ "$options_with_args" "$boolean_options" 2514 } 2515 2516 _podman_wait() { 2517 local options_with_args="" 2518 local boolean_options=" 2519 --help 2520 -h 2521 -i 2522 -l 2523 --interval 2524 --latest 2525 " 2526 case "$cur" in 2527 -*) 2528 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2529 ;; 2530 *) 2531 __podman_complete_container_names 2532 ;; 2533 esac 2534 } 2535 2536 _complete_() { 2537 local options_with_args=$1 2538 local boolean_options="$2 -h --help" 2539 2540 case "$prev" in 2541 $options_with_args) 2542 return 2543 ;; 2544 esac 2545 2546 case "$cur" in 2547 -*) 2548 COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) 2549 ;; 2550 esac 2551 } 2552 2553 _podman_load() { 2554 local options_with_args=" 2555 --input -i 2556 " 2557 local boolean_options=" 2558 --help 2559 -h 2560 --quiet 2561 -q 2562 " 2563 _complete_ "$options_with_args" "$boolean_options" 2564 } 2565 2566 _podman_cp() { 2567 local boolean_options=" 2568 --help 2569 -h 2570 --extract 2571 --pause 2572 " 2573 _complete_ "$boolean_options" 2574 } 2575 2576 _podman_login() { 2577 local options_with_args=" 2578 --username 2579 -u 2580 --password 2581 -p 2582 --authfile 2583 --get-login 2584 " 2585 local boolean_options=" 2586 --help 2587 -h 2588 --password-stdin 2589 " 2590 _complete_ "$options_with_args" "$boolean_options" 2591 } 2592 2593 _podman_logout() { 2594 local options_with_args=" 2595 --authfile 2596 " 2597 local boolean_options=" 2598 --all 2599 -a 2600 --help 2601 -h 2602 " 2603 _complete_ "$options_with_args" "$boolean_options" 2604 } 2605 2606 _podman_healthcheck_run() { 2607 local options_with_args="" 2608 2609 local boolean_options=" 2610 -h 2611 --help 2612 " 2613 2614 case "$cur" in 2615 -*) 2616 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2617 ;; 2618 *) 2619 COMPREPLY=( $( compgen -W " 2620 $(__podman_containers --all) 2621 " -- "$cur" ) ) 2622 __ltrim_colon_completions "$cur" 2623 ;; 2624 esac 2625 } 2626 2627 _podman_generate_kube() { 2628 local options_with_args=" 2629 --filename -f 2630 " 2631 2632 local boolean_options=" 2633 -h 2634 --help 2635 -s 2636 --service 2637 " 2638 2639 case "$cur" in 2640 -*) 2641 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2642 ;; 2643 *) 2644 COMPREPLY=( $( compgen -W " 2645 $(__podman_containers --all) 2646 $(__podman_pods) 2647 " -- "$cur" ) ) 2648 __ltrim_colon_completions "$cur" 2649 ;; 2650 esac 2651 } 2652 2653 _podman_generate_systemd() { 2654 local options_with_args=" 2655 --restart-policy 2656 -t 2657 --time" 2658 2659 local boolean_options=" 2660 -h 2661 --help 2662 -n 2663 --name 2664 " 2665 2666 case "$cur" in 2667 -*) 2668 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2669 ;; 2670 *) 2671 COMPREPLY=( $( compgen -W " 2672 $(__podman_containers --all) 2673 " -- "$cur" ) ) 2674 __ltrim_colon_completions "$cur" 2675 ;; 2676 esac 2677 } 2678 2679 _podman_play_kube() { 2680 local options_with_args=" 2681 --authfile 2682 --cert-dir 2683 --creds 2684 --network 2685 " 2686 2687 local boolean_options=" 2688 -h 2689 --help 2690 --quiet 2691 -q 2692 --tls-verify 2693 --seccomp-profile-root 2694 " 2695 2696 case "$cur" in 2697 -*) 2698 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2699 ;; 2700 *) 2701 _filedir 2702 ;; 2703 esac 2704 } 2705 2706 _podman_events() { 2707 local options_with_args=" 2708 --help 2709 --h 2710 --filter 2711 --format 2712 --since 2713 --until 2714 " 2715 case "$cur" in 2716 -*) 2717 COMPREPLY=($(compgen -W "$options_with_args" -- "$cur")) 2718 ;; 2719 esac 2720 } 2721 2722 _podman_container_runlabel() { 2723 local options_with_args=" 2724 --authfile 2725 --cert-dir 2726 --creds 2727 --name 2728 " 2729 2730 local boolean_options=" 2731 --display 2732 --help 2733 -h 2734 -q 2735 --quiet 2736 --replace 2737 --tls-verify 2738 " 2739 2740 case "$cur" in 2741 -*) 2742 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2743 ;; 2744 *) 2745 __podman_complete_images --id 2746 ;; 2747 esac 2748 } 2749 2750 _podman_image_sign() { 2751 local options_with_args=" 2752 --cert-dir 2753 -d 2754 --directory 2755 --sign-by 2756 " 2757 local boolean_options=" 2758 --help 2759 -h 2760 " 2761 case "$cur" in 2762 -*) 2763 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2764 ;; 2765 *) 2766 __podman_complete_images 2767 ;; 2768 esac 2769 } 2770 2771 _podman_image_trust_set() { 2772 echo hello 2773 local options_with_args=" 2774 -f 2775 --type 2776 --pubkeysfile 2777 " 2778 local boolean_options=" 2779 --help 2780 -h 2781 " 2782 case "$cur" in 2783 -*) 2784 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2785 ;; 2786 *) 2787 COMPREPLY=($(compgen -W "default $( __podman_list_registries )" -- "$cur")) 2788 ;; 2789 esac 2790 } 2791 2792 _podman_image_trust_show() { 2793 local options_with_args=" 2794 " 2795 local boolean_options=" 2796 --help 2797 -h 2798 -j 2799 --json 2800 --raw 2801 " 2802 case "$cur" in 2803 -*) 2804 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2805 ;; 2806 *) 2807 __podman_complete_images 2808 ;; 2809 esac 2810 } 2811 2812 _podman_image_trust() { 2813 local boolean_options=" 2814 --help 2815 -h 2816 " 2817 subcommands=" 2818 set 2819 show 2820 " 2821 local aliases=" 2822 list 2823 " 2824 command=image_trust 2825 __podman_subcommands "$subcommands $aliases" && return 2826 2827 case "$cur" in 2828 -*) 2829 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2830 ;; 2831 *) 2832 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 2833 ;; 2834 esac 2835 } 2836 2837 _podman_images_prune() { 2838 local options_with_args=" 2839 " 2840 2841 local boolean_options=" 2842 -a 2843 --all 2844 -h 2845 --help 2846 " 2847 case "$cur" in 2848 -*) 2849 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2850 ;; 2851 esac 2852 } 2853 2854 _podman_container_prune() { 2855 local options_with_args=" 2856 --filter 2857 " 2858 2859 local boolean_options=" 2860 -f 2861 --force 2862 -h 2863 --help 2864 " 2865 case "$cur" in 2866 -*) 2867 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2868 ;; 2869 esac 2870 } 2871 2872 _podman_container_exists() { 2873 local options_with_args=" 2874 " 2875 2876 local boolean_options=" 2877 " 2878 case "$cur" in 2879 -*) 2880 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2881 ;; 2882 *) 2883 __podman_complete_images 2884 ;; 2885 esac 2886 2887 } 2888 2889 _podman_pod_exists() { 2890 local options_with_args=" 2891 " 2892 2893 local boolean_options=" 2894 " 2895 } 2896 2897 _podman_image_exists() { 2898 local options_with_args=" 2899 " 2900 2901 local boolean_options=" 2902 " 2903 } 2904 2905 _podman_pod_create() { 2906 local options_with_args=" 2907 --add-host 2908 --cgroup-parent 2909 --dns 2910 --dns-opt 2911 --dns-search 2912 --infra-command 2913 --infra-image 2914 --ip 2915 --label-file 2916 --label 2917 -l 2918 --mac-address 2919 --name 2920 --network 2921 --no-hosts 2922 --podidfile 2923 --publish 2924 -p 2925 --share 2926 " 2927 2928 local boolean_options=" 2929 --help 2930 -h 2931 --infra 2932 " 2933 _complete_ "$options_with_args" "$boolean_options" 2934 } 2935 2936 _podman_pod_kill() { 2937 local options_with_args=" 2938 " 2939 2940 local boolean_options=" 2941 --all 2942 -a 2943 --help 2944 -h 2945 --signal 2946 -s 2947 --latest 2948 -l 2949 " 2950 _complete_ "$options_with_args" "$boolean_options" 2951 case "$cur" in 2952 -*) 2953 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 2954 ;; 2955 *) 2956 __podman_complete_pod_names 2957 ;; 2958 esac 2959 } 2960 2961 __podman_pod_ps() { 2962 local options_with_args=" 2963 -f 2964 --filter 2965 --format 2966 --sort 2967 " 2968 2969 local boolean_options=" 2970 --cgroup 2971 --ctr-ids 2972 --ctr-names 2973 --ctr-status 2974 --help 2975 -h 2976 -q 2977 --quiet 2978 --no-trunc 2979 --labels 2980 -l 2981 --latest 2982 " 2983 _complete_ "$options_with_args" "$boolean_options" 2984 } 2985 2986 _podman_pod_ls() { 2987 __podman_pod_ps 2988 } 2989 2990 _podman_pod_list() { 2991 __podman_pod_ps 2992 } 2993 2994 _podman_pod_ps() { 2995 __podman_pod_ps 2996 } 2997 2998 _podman_pod_prune() { 2999 local options_with_args=" 3000 " 3001 3002 local boolean_options=" 3003 -f 3004 -h 3005 --help 3006 " 3007 case "$cur" in 3008 -*) 3009 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 3010 ;; 3011 esac 3012 } 3013 3014 _podman_pod_restart() { 3015 local options_with_args=" 3016 " 3017 3018 local boolean_options=" 3019 --all 3020 -a 3021 --help 3022 -h 3023 --latest 3024 -l 3025 " 3026 _complete_ "$options_with_args" "$boolean_options" 3027 case "$cur" in 3028 -*) 3029 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 3030 ;; 3031 *) 3032 __podman_complete_pod_names 3033 ;; 3034 esac 3035 } 3036 3037 _podman_pod_rm() { 3038 local options_with_args=" 3039 " 3040 3041 local boolean_options=" 3042 -a 3043 --all 3044 --help 3045 -h 3046 --ignore 3047 -i 3048 -f 3049 --force 3050 --latest 3051 -l 3052 " 3053 _complete_ "$options_with_args" "$boolean_options" 3054 case "$cur" in 3055 -*) 3056 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 3057 ;; 3058 *) 3059 __podman_complete_pod_names 3060 ;; 3061 esac 3062 } 3063 3064 _podman_pod_start() { 3065 local options_with_args=" 3066 " 3067 3068 local boolean_options=" 3069 --all 3070 -a 3071 --help 3072 -h 3073 --latest 3074 -l 3075 " 3076 _complete_ "$options_with_args" "$boolean_options" 3077 case "$cur" in 3078 -*) 3079 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 3080 ;; 3081 *) 3082 __podman_complete_pod_names 3083 ;; 3084 esac 3085 } 3086 3087 _podman_pod_stop() { 3088 local options_with_args=" 3089 -t 3090 --time 3091 " 3092 3093 local boolean_options=" 3094 --all 3095 -a 3096 --cleanup 3097 --help 3098 --ignore 3099 -i 3100 -h 3101 --latest 3102 -l 3103 " 3104 _complete_ "$options_with_args" "$boolean_options" 3105 case "$cur" in 3106 -*) 3107 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 3108 ;; 3109 *) 3110 __podman_complete_pod_names 3111 ;; 3112 esac 3113 } 3114 3115 _podman_pod_pause() { 3116 local options_with_args=" 3117 " 3118 3119 local boolean_options=" 3120 --all 3121 -a 3122 --help 3123 -h 3124 --latest 3125 -l 3126 " 3127 _complete_ "$options_with_args" "$boolean_options" 3128 case "$cur" in 3129 -*) 3130 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 3131 ;; 3132 *) 3133 __podman_complete_pod_names 3134 ;; 3135 esac 3136 } 3137 3138 _podman_pod_unpause() { 3139 local options_with_args=" 3140 " 3141 3142 local boolean_options=" 3143 --all 3144 -a 3145 --help 3146 -h 3147 --latest 3148 -l 3149 " 3150 _complete_ "$options_with_args" "$boolean_options" 3151 case "$cur" in 3152 -*) 3153 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 3154 ;; 3155 *) 3156 __podman_complete_pod_names 3157 ;; 3158 esac 3159 } 3160 3161 _podman_pod() { 3162 local boolean_options=" 3163 --help 3164 -h 3165 " 3166 subcommands=" 3167 create 3168 kill 3169 pause 3170 ps 3171 restart 3172 rm 3173 start 3174 stats 3175 stop 3176 top 3177 unpause 3178 " 3179 local aliases=" 3180 list 3181 ls 3182 " 3183 __podman_subcommands "$subcommands $aliases" && return 3184 3185 case "$cur" in 3186 -*) 3187 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3188 ;; 3189 *) 3190 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 3191 ;; 3192 esac 3193 } 3194 3195 _podman_volume_create() { 3196 local options_with_args=" 3197 --driver 3198 --label 3199 -l 3200 --opt 3201 -o 3202 " 3203 3204 local boolean_options=" 3205 --help 3206 -h 3207 " 3208 3209 _complete_ "$options_with_args" "$boolean_options" 3210 } 3211 3212 _podman_volume_ls() { 3213 local options_with_args=" 3214 --filter 3215 --format 3216 -f 3217 " 3218 3219 local boolean_options=" 3220 --help 3221 -h 3222 --quiet 3223 -q 3224 " 3225 3226 _complete_ "$options_with_args" "$boolean_options" 3227 } 3228 3229 _podman_volume_inspect() { 3230 local options_with_args=" 3231 --format 3232 -f 3233 " 3234 3235 local boolean_options=" 3236 --all 3237 -a 3238 --help 3239 -h 3240 " 3241 3242 _complete_ "$options_with_args" "$boolean_options" 3243 case "$cur" in 3244 -*) 3245 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 3246 ;; 3247 *) 3248 __podman_complete_volume_names 3249 ;; 3250 esac 3251 } 3252 3253 _podman_volume_rm() { 3254 local options_with_args="" 3255 3256 local boolean_options=" 3257 --all 3258 -a 3259 --force 3260 -f 3261 --help 3262 -h 3263 " 3264 3265 _complete_ "$options_with_args" "$boolean_options" 3266 case "$cur" in 3267 -*) 3268 COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) 3269 ;; 3270 *) 3271 __podman_complete_volume_names 3272 ;; 3273 esac 3274 } 3275 3276 _podman_volume_prune() { 3277 local options_with_args="" 3278 3279 local boolean_options=" 3280 --force 3281 -f 3282 --help 3283 -h 3284 " 3285 3286 _complete_ "$options_with_args" "$boolean_options" 3287 } 3288 3289 _podman_volume() { 3290 local boolean_options=" 3291 --help 3292 -h 3293 " 3294 subcommands=" 3295 create 3296 inspect 3297 ls 3298 rm 3299 prune 3300 " 3301 local aliases=" 3302 list 3303 remove 3304 " 3305 __podman_subcommands "$subcommands $aliases" && return 3306 3307 case "$cur" in 3308 -*) 3309 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3310 ;; 3311 *) 3312 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 3313 ;; 3314 esac 3315 } 3316 3317 _podman_podman() { 3318 local options_with_args=" 3319 --config -c 3320 --root 3321 --runroot 3322 --storage-driver 3323 --storage-opt 3324 --log-level 3325 --namespace 3326 " 3327 local boolean_options=" 3328 --help 3329 -h 3330 --version 3331 -v 3332 --syslog 3333 " 3334 commands=" 3335 attach 3336 auto-update 3337 build 3338 commit 3339 container 3340 cp 3341 create 3342 diff 3343 events 3344 exec 3345 export 3346 generate 3347 healthcheck 3348 history 3349 image 3350 images 3351 import 3352 info 3353 inspect 3354 kill 3355 load 3356 login 3357 logout 3358 logs 3359 mount 3360 pause 3361 pod 3362 port 3363 ps 3364 pull 3365 push 3366 play 3367 restart 3368 rm 3369 rmi 3370 run 3371 save 3372 search 3373 start 3374 stats 3375 stop 3376 tag 3377 top 3378 umount 3379 unmount 3380 unpause 3381 varlink 3382 version 3383 volume 3384 wait 3385 " 3386 3387 case "$prev" in 3388 $main_options_with_args_glob ) 3389 return 3390 ;; 3391 esac 3392 3393 case "$cur" in 3394 -*) 3395 COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) 3396 ;; 3397 *) 3398 COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) ) 3399 ;; 3400 esac 3401 } 3402 3403 _cli_bash_autocomplete() { 3404 local cur opts base 3405 3406 COMPREPLY=() 3407 cur="${COMP_WORDS[COMP_CWORD]}" 3408 COMPREPLY=() 3409 local cur prev words cword 3410 3411 _get_comp_words_by_ref -n : cur prev words cword 3412 3413 local command=${PROG} cpos=0 3414 local counter=1 3415 counter=1 3416 while [ $counter -lt $cword ]; do 3417 case "!${words[$counter]}" in 3418 *) 3419 command=$(echo "${words[$counter]}" | sed 's/-/_/g') 3420 cpos=$counter 3421 (( cpos++ )) 3422 break 3423 ;; 3424 esac 3425 (( counter++ )) 3426 done 3427 3428 local completions_func=_podman_${command} 3429 declare -F $completions_func >/dev/null && $completions_func 3430 3431 eval "$previous_extglob_setting" 3432 return 0 3433 } 3434 3435 complete -F _cli_bash_autocomplete podman