mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
Update lxd.plugin.zsh
- Add elements listing - Add instance listing - Separate Flags, Global Flags, Commands
This commit is contained in:
parent
5d3e86e2a4
commit
eb5287383d
1 changed files with 64 additions and 5 deletions
|
@ -1,9 +1,64 @@
|
|||
_lxc_get_command_list () {
|
||||
$_comp_command1 | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
|
||||
_lxc_get_commands () {
|
||||
sed '/Available Commands/,/Flags/!d' | awk '/^[ \t]/{ print $1 }'
|
||||
}
|
||||
_lxc_get_flags () {
|
||||
sed '/^Flags/,/^Global Flags/!d' | awk '/^[ \t]*--/ { print $1 }/^[ \t]*-.,/ { print $1 $2 }' | sed 's/,/ /'
|
||||
}
|
||||
_lxc_get_global_flags () {
|
||||
sed '/^Global Flags/,$!d' | awk '/^[ \t]*--/ { print $1 }/^[ \t]*-.,/ { print $1 $2 }' | sed 's/,/ /'
|
||||
}
|
||||
|
||||
_lxc_get_command_list () {
|
||||
echo "___command"
|
||||
$_comp_command1 -h | _lxc_get_commands
|
||||
$_comp_command1 -h | _lxc_get_global_flags
|
||||
}
|
||||
|
||||
|
||||
_lxc_get_subcommand_list () {
|
||||
$_comp_command1 ${words[2]} | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
|
||||
|
||||
$_comp_command1 ${words[2]} -h | _lxc_get_flags
|
||||
$_comp_command1 ${words[2]} -h | _lxc_get_commands
|
||||
|
||||
case ${words[2]} in
|
||||
alias|cluster|image|operation|profile|project|remote|storage|warning)
|
||||
echo "___subco_alias"
|
||||
${words[1]} ${words[2]} list -f csv | cut -d, -f1
|
||||
;;
|
||||
list)
|
||||
echo "___subco_list"
|
||||
${words[1]} ${words[2]} -cn -fcsv ${words[3]}
|
||||
;;
|
||||
exec)
|
||||
echo "___subco_exec"
|
||||
echo "--"
|
||||
${words[1]} list -cn -fcsv ${words[3]}
|
||||
;;
|
||||
network)
|
||||
echo "___subco_autre"
|
||||
${words[1]} ${words[2]} list -fcsv | cut -d, -f1
|
||||
;;
|
||||
*)
|
||||
echo "___subco_autre"
|
||||
${words[1]} list -cn -fcsv ${words[3]}
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
_lxc_get_element_list () {
|
||||
case ${words[2]} in
|
||||
exec)
|
||||
echo "___subco_exec2"
|
||||
echo "--"
|
||||
$_comp_command1 ${words[2]} -h | _lxc_get_flags
|
||||
;;
|
||||
*)
|
||||
echo "___subco_autre2"
|
||||
$_comp_command1 ${words[2]} ${words[3]} -h | _lxc_get_flags
|
||||
$_comp_command1 ${words[2]} ${words[3]} -h | _lxc_get_commands
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_lxc () {
|
||||
|
@ -11,16 +66,20 @@ _lxc () {
|
|||
typeset -A opt_args
|
||||
_arguments \
|
||||
'1: :->command'\
|
||||
'2: :->subcommand'\
|
||||
'*: :->args'
|
||||
|
||||
case $state in
|
||||
command)
|
||||
compadd $(_lxc_get_command_list)
|
||||
;;
|
||||
subcommand)
|
||||
compadd $(_lxc_get_subcommand_list)
|
||||
;;
|
||||
*)
|
||||
compadd $(_lxc_get_subcommand_list)
|
||||
compadd $(_lxc_get_element_list)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
compdef _lxc lxc
|
||||
compdef _lxc lxc lxd
|
||||
|
|
Loading…
Reference in a new issue