You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
913 B
33 lines
913 B
function _incus_container {
|
|
incus list --format csv --columns n
|
|
}
|
|
|
|
function _active_users {
|
|
echo root
|
|
miaou-exec "$container" -- awk -F: '$3 >= 1000 && $7 !~ /nologin|false/ {print $1}' /etc/passwd
|
|
}
|
|
|
|
function _miaou_login {
|
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
|
local prev="${COMP_WORDS[COMP_CWORD - 1]}"
|
|
local container="${COMP_WORDS[1]}"
|
|
|
|
case $COMP_CWORD in
|
|
1)
|
|
# first argument — containers
|
|
COMPREPLY=($(compgen -W "$(_incus_container)" -- "$cur"))
|
|
;;
|
|
2)
|
|
# second argument - options
|
|
COMPREPLY=($(compgen -W "--user -u" -- "$cur"))
|
|
;;
|
|
3)
|
|
if [[ $prev =~ ^(--user|-u) ]]; then
|
|
# user expected
|
|
COMPREPLY=($(compgen -W "$(_active_users "$container")" -- "$cur"))
|
|
fi
|
|
;;
|
|
esac
|
|
}
|
|
|
|
complete -F _miaou_login "miaou-login"
|