2016-12-02 15:15:15 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
: ${PROG:=$(basename ${BASH_SOURCE})}
|
|
|
|
|
2017-06-16 17:24:00 +00:00
|
|
|
__kpod_list_images() {
|
|
|
|
COMPREPLY=($(compgen -W "$(kpod images -q)" -- $cur))
|
|
|
|
}
|
|
|
|
|
2017-07-21 15:23:48 +00:00
|
|
|
__kpod_list_containers() {
|
|
|
|
COMPREPLY=($(compgen -W "$(kpod ps -aq)" -- $cur))
|
|
|
|
}
|
|
|
|
|
2017-08-17 19:12:24 +00:00
|
|
|
_kpod_diff() {
|
|
|
|
local options_with_args="
|
|
|
|
--format
|
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
__kpod_list_images
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
_kpod_export() {
|
|
|
|
local options_with_args="
|
|
|
|
--output
|
|
|
|
-o
|
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
__kpod_list_images
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-06-29 19:16:06 +00:00
|
|
|
_kpod_history() {
|
2017-08-17 19:12:24 +00:00
|
|
|
local options_with_args="
|
2017-06-29 19:16:06 +00:00
|
|
|
--format
|
|
|
|
"
|
2017-08-17 19:12:24 +00:00
|
|
|
local boolean_options="
|
2017-06-29 19:16:06 +00:00
|
|
|
--human -H
|
|
|
|
--no-trunc
|
|
|
|
--quiet -q
|
|
|
|
"
|
2017-08-17 19:12:24 +00:00
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
2017-06-29 19:16:06 +00:00
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
__kpod_list_images
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-08-10 17:58:29 +00:00
|
|
|
_kpod_info() {
|
|
|
|
local boolean_options="
|
|
|
|
--help
|
|
|
|
-h
|
|
|
|
--debug
|
|
|
|
"
|
|
|
|
local options_with_args="
|
2017-08-14 19:32:00 +00:00
|
|
|
--format
|
2017-08-10 17:58:29 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
local all_options="$options_with_args $boolean_options"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
2017-08-17 19:12:24 +00:00
|
|
|
*)
|
|
|
|
__kpod_list_images
|
|
|
|
;;
|
2017-08-10 17:58:29 +00:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-06-16 17:24:00 +00:00
|
|
|
_kpod_images() {
|
|
|
|
local boolean_options="
|
|
|
|
--help
|
|
|
|
-h
|
|
|
|
--quiet
|
|
|
|
-q
|
|
|
|
--noheading
|
|
|
|
-n
|
|
|
|
--no-trunc
|
|
|
|
--digests
|
|
|
|
--filter
|
|
|
|
-f
|
2017-06-16 17:24:00 +00:00
|
|
|
"
|
2017-06-16 17:24:00 +00:00
|
|
|
local options_with_args="
|
2017-07-31 18:02:57 +00:00
|
|
|
--format
|
2017-06-16 17:24:00 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
local all_options="$options_with_args $boolean_options"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
esac
|
2017-08-10 17:58:29 +00:00
|
|
|
}
|
2017-06-16 17:24:00 +00:00
|
|
|
|
2017-08-17 19:12:24 +00:00
|
|
|
_kpod_inspect() {
|
|
|
|
local boolean_options="
|
|
|
|
--help
|
|
|
|
-h
|
2017-06-16 17:24:00 +00:00
|
|
|
"
|
2017-08-17 19:12:24 +00:00
|
|
|
local options_with_args="
|
|
|
|
--format
|
|
|
|
-f
|
|
|
|
--type
|
|
|
|
-t
|
|
|
|
--size
|
|
|
|
"
|
|
|
|
|
|
|
|
local all_options="$options_with_args $boolean_options"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
esac
|
2017-06-16 17:24:00 +00:00
|
|
|
}
|
2017-09-13 20:56:27 +00:00
|
|
|
_kpod_kill() {
|
|
|
|
local options_with_args="
|
|
|
|
--signal -s
|
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
--help
|
|
|
|
-h"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
2017-06-16 17:24:00 +00:00
|
|
|
|
2017-07-21 15:23:48 +00:00
|
|
|
_kpod_logs() {
|
|
|
|
local options_with_args="
|
|
|
|
--since
|
|
|
|
--tail
|
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
--follow
|
|
|
|
-f
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
__kpod_list_containers
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-06-16 17:24:00 +00:00
|
|
|
_kpod_pull() {
|
|
|
|
local options_with_args="
|
2017-10-13 21:04:57 +00:00
|
|
|
--authfile
|
|
|
|
--creds
|
2017-10-13 00:35:08 +00:00
|
|
|
--signature-policy
|
2017-06-16 17:24:00 +00:00
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
--all-tags -a
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
2016-12-02 15:15:15 +00:00
|
|
|
|
2017-07-31 19:35:14 +00:00
|
|
|
_kpod_unmount() {
|
|
|
|
_kpod_umount $@
|
|
|
|
}
|
|
|
|
|
|
|
|
_kpod_umount() {
|
|
|
|
local boolean_options="
|
|
|
|
--help
|
|
|
|
-h
|
|
|
|
"
|
|
|
|
local options_with_args="
|
|
|
|
"
|
|
|
|
|
|
|
|
local all_options="$options_with_args $boolean_options"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
_kpod_mount() {
|
|
|
|
local boolean_options="
|
|
|
|
--help
|
|
|
|
-h
|
|
|
|
--notruncate
|
|
|
|
"
|
|
|
|
|
|
|
|
local options_with_args="
|
|
|
|
--label
|
|
|
|
--format
|
|
|
|
"
|
|
|
|
|
|
|
|
local all_options="$options_with_args $boolean_options"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-06-16 17:24:00 +00:00
|
|
|
_kpod_push() {
|
|
|
|
local boolean_options="
|
2017-10-13 21:04:57 +00:00
|
|
|
--disable-compression
|
|
|
|
-D
|
|
|
|
--quiet
|
|
|
|
-q
|
|
|
|
--remove-signatures
|
|
|
|
--tls-verify
|
2017-06-16 17:24:00 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
local options_with_args="
|
2017-10-13 21:04:57 +00:00
|
|
|
--authfile
|
|
|
|
--cert-dir
|
|
|
|
--creds
|
|
|
|
--sign-by
|
|
|
|
--signature-policy
|
2017-06-16 17:24:00 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
local all_options="$options_with_args $boolean_options"
|
2016-12-02 15:15:15 +00:00
|
|
|
|
|
|
|
case "$cur" in
|
2017-06-16 17:24:00 +00:00
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
2016-12-02 15:15:15 +00:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-08-14 17:30:24 +00:00
|
|
|
_kpod_rename() {
|
|
|
|
local boolean_options="
|
|
|
|
--help
|
|
|
|
-h
|
|
|
|
"
|
|
|
|
local options_with_args="
|
|
|
|
"
|
|
|
|
|
|
|
|
local all_options="$options_with_args $boolean_options"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
__kpod_list_containers
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-08-30 20:03:26 +00:00
|
|
|
_kpod_rm() {
|
|
|
|
local boolean_options="
|
|
|
|
--force
|
|
|
|
-f
|
|
|
|
"
|
|
|
|
|
|
|
|
local options_with_args="
|
|
|
|
"
|
|
|
|
|
|
|
|
local all_options="$options_with_args $boolean_options"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
__kpod_list_containers
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-06-16 17:24:00 +00:00
|
|
|
_kpod_rmi() {
|
|
|
|
local boolean_options="
|
|
|
|
--help
|
|
|
|
-h
|
|
|
|
--force
|
|
|
|
-f
|
|
|
|
"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
__kpod_list_images
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-07-25 13:56:23 +00:00
|
|
|
_kpod_stats() {
|
|
|
|
local boolean_options="
|
|
|
|
--help
|
|
|
|
--all
|
|
|
|
-a
|
|
|
|
--no-stream
|
|
|
|
--format
|
|
|
|
"
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
__kpod_list_containers
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2017-06-16 17:24:00 +00:00
|
|
|
kpod_tag() {
|
|
|
|
local options_with_args="
|
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
|
|
|
|
2017-06-16 16:27:06 +00:00
|
|
|
_kpod_version() {
|
|
|
|
local options_with_args="
|
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
2017-06-30 19:10:57 +00:00
|
|
|
}
|
2017-06-27 13:45:25 +00:00
|
|
|
|
2017-07-14 14:31:02 +00:00
|
|
|
_kpod_save() {
|
|
|
|
local options_with_args="
|
|
|
|
--output -o
|
2017-08-02 20:32:44 +00:00
|
|
|
--format
|
2017-07-14 14:31:02 +00:00
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
--quiet -q
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
|
|
|
|
2017-08-07 14:30:10 +00:00
|
|
|
_kpod_export() {
|
|
|
|
local options_with_args="
|
|
|
|
--output -o
|
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
|
|
|
|
2017-09-19 12:26:32 +00:00
|
|
|
_kpod_pause() {
|
|
|
|
local options_with_args="
|
|
|
|
--help -h
|
|
|
|
"
|
|
|
|
local boolean_options=""
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
|
|
|
|
2017-08-08 13:24:58 +00:00
|
|
|
_kpod_ps() {
|
|
|
|
local options_with_args="
|
|
|
|
--filter -f
|
|
|
|
--format
|
|
|
|
--last -n
|
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
--all -a
|
|
|
|
--latest -l
|
|
|
|
--no-trunc
|
|
|
|
--quiet -q
|
|
|
|
--size -s
|
2017-09-08 19:50:33 +00:00
|
|
|
--namespace --ns
|
2017-08-08 13:24:58 +00:00
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
|
|
|
|
2017-09-06 17:30:34 +00:00
|
|
|
_kpod_stop() {
|
|
|
|
local options_with_args="
|
|
|
|
--timeout -t
|
|
|
|
"
|
|
|
|
local boolean_options=""
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
|
|
|
|
2017-09-19 12:26:32 +00:00
|
|
|
_kpod_unpause() {
|
|
|
|
local options_with_args="
|
|
|
|
--help -h
|
|
|
|
"
|
|
|
|
local boolean_options=""
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
2017-09-19 17:45:08 +00:00
|
|
|
|
|
|
|
_kpod_wait() {
|
|
|
|
local options_with_args=""
|
|
|
|
local boolean_options="--help -h"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
2017-09-19 12:26:32 +00:00
|
|
|
}
|
|
|
|
|
2017-06-16 17:24:00 +00:00
|
|
|
_complete_() {
|
|
|
|
local options_with_args=$1
|
|
|
|
local boolean_options="$2 -h --help"
|
2017-06-16 16:27:06 +00:00
|
|
|
|
2017-06-16 17:24:00 +00:00
|
|
|
case "$prev" in
|
|
|
|
$options_with_args)
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
|
|
|
;;
|
|
|
|
esac
|
2017-06-30 19:10:57 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 17:37:16 +00:00
|
|
|
_kpod_load() {
|
|
|
|
local options_with_args="
|
|
|
|
--input -i
|
2017-10-13 00:35:08 +00:00
|
|
|
--signature-policy
|
2017-07-12 17:37:16 +00:00
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
--quiet -q
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
|
|
|
|
2017-08-22 20:40:18 +00:00
|
|
|
_kpod_login() {
|
|
|
|
local options_with_args="
|
|
|
|
--username
|
|
|
|
-u
|
|
|
|
--password
|
|
|
|
-p
|
|
|
|
--authfile
|
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
--help
|
|
|
|
-h
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
|
|
|
|
|
|
|
_kpod_logout() {
|
|
|
|
local options_with_args="
|
|
|
|
--authfile
|
|
|
|
"
|
|
|
|
local boolean_options="
|
|
|
|
--all
|
|
|
|
-a
|
|
|
|
--help
|
|
|
|
-h
|
|
|
|
"
|
|
|
|
_complete_ "$options_with_args" "$boolean_options"
|
|
|
|
}
|
|
|
|
|
2016-12-02 15:15:15 +00:00
|
|
|
_kpod_kpod() {
|
|
|
|
local options_with_args="
|
2017-08-10 17:58:29 +00:00
|
|
|
--config -c
|
|
|
|
--root
|
|
|
|
--runroot
|
|
|
|
--storage-driver
|
|
|
|
--storage-opt
|
2017-10-09 17:47:21 +00:00
|
|
|
--log-level
|
2017-08-10 17:58:29 +00:00
|
|
|
"
|
2016-12-02 15:15:15 +00:00
|
|
|
local boolean_options="
|
2017-08-10 17:58:29 +00:00
|
|
|
--help -h
|
|
|
|
--version -v
|
2016-12-02 15:15:15 +00:00
|
|
|
"
|
|
|
|
commands="
|
2017-08-17 19:12:24 +00:00
|
|
|
diff
|
|
|
|
export
|
2017-07-31 19:35:14 +00:00
|
|
|
history
|
2017-06-16 17:24:00 +00:00
|
|
|
images
|
2017-08-10 17:58:29 +00:00
|
|
|
info
|
2017-08-17 19:12:24 +00:00
|
|
|
inspect
|
2017-09-13 20:56:27 +00:00
|
|
|
kill
|
2017-07-31 19:35:14 +00:00
|
|
|
load
|
2017-08-22 20:40:18 +00:00
|
|
|
login
|
|
|
|
logout
|
2017-08-17 19:12:24 +00:00
|
|
|
logs
|
2017-07-31 19:35:14 +00:00
|
|
|
mount
|
2017-09-19 12:26:32 +00:00
|
|
|
pause
|
2017-08-08 13:24:58 +00:00
|
|
|
ps
|
2017-07-31 19:35:14 +00:00
|
|
|
pull
|
2017-06-16 17:24:00 +00:00
|
|
|
push
|
2017-08-17 19:12:24 +00:00
|
|
|
rename
|
2017-08-30 20:03:26 +00:00
|
|
|
rm
|
2017-06-16 17:24:00 +00:00
|
|
|
rmi
|
2017-08-17 19:12:24 +00:00
|
|
|
save
|
2017-07-25 13:56:23 +00:00
|
|
|
stats
|
2017-09-06 17:30:34 +00:00
|
|
|
stop
|
2017-06-27 13:45:25 +00:00
|
|
|
tag
|
2017-07-31 19:35:14 +00:00
|
|
|
umount
|
|
|
|
unmount
|
2017-09-19 12:26:32 +00:00
|
|
|
unpause
|
2017-06-16 16:27:06 +00:00
|
|
|
version
|
2017-09-19 17:45:08 +00:00
|
|
|
wait
|
2016-12-02 15:15:15 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
case "$prev" in
|
|
|
|
$main_options_with_args_glob )
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
-*)
|
|
|
|
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
_cli_bash_autocomplete() {
|
|
|
|
local cur opts base
|
|
|
|
|
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
COMPREPLY=()
|
|
|
|
local cur prev words cword
|
|
|
|
|
|
|
|
_get_comp_words_by_ref -n : cur prev words cword
|
|
|
|
|
|
|
|
local command=${PROG} cpos=0
|
|
|
|
local counter=1
|
|
|
|
counter=1
|
|
|
|
while [ $counter -lt $cword ]; do
|
|
|
|
case "!${words[$counter]}" in
|
|
|
|
*)
|
|
|
|
command=$(echo "${words[$counter]}" | sed 's/-/_/g')
|
|
|
|
cpos=$counter
|
|
|
|
(( cpos++ ))
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
(( counter++ ))
|
|
|
|
done
|
|
|
|
|
|
|
|
local completions_func=_kpod_${command}
|
|
|
|
declare -F $completions_func >/dev/null && $completions_func
|
|
|
|
|
|
|
|
eval "$previous_extglob_setting"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
complete -F _cli_bash_autocomplete $PROG
|