]> git.ipfire.org Git - thirdparty/systemd.git/blob - shell-completion/zsh/_machinectl
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / shell-completion / zsh / _machinectl
1 #compdef machinectl
2 # SPDX-License-Identifier: LGPL-2.1+
3
4 (( $+functions[__machinectl_get_machines] )) ||
5 __machinectl_get_machines () {
6 machinectl --no-legend list-images | {while read -r a b; do echo $a; done;}
7 }
8
9 (( $+functions[_machinectl_machines] )) ||
10 _machinectl_machines() {
11 local -a _machines
12 _machines=("${(fo)$(__machinectl_get_machines)}")
13 typeset -U _machines
14 if [[ -n "$_machines" ]]; then
15 _describe 'machines' _machines
16 else
17 _message 'no machines'
18 fi
19 }
20
21 (( $+functions[_machinectl_commands] )) || _machinectl_commands()
22 {
23 local -a _machinectl_cmds
24 _machinectl_cmds=(
25 "list:List currently running VMs/containers"
26 "status:Show VM/container status"
27 "show:Show properties of one or more VMs/containers"
28 "start:Start container as a service"
29 "stop:Stop container (equal to poweroff)"
30 "login:Get a login prompt on a VM/container"
31 "enable:Enable automatic container start at boot"
32 "disable:Disable automatic container start at boot"
33 "poweroff:Power off one or more VMs/containers"
34 "reboot:Reboot one or more VMs/containers"
35 "terminate:Terminate one or more VMs/containers"
36 "kill:Send signal to process or a VM/container"
37 "copy-to:Copy files from the host to a container"
38 "copy-from:Copy files from a container to the host"
39 "bind:Bind mount a path from the host into a container"
40
41 "list-images:Show available container and VM images"
42 "image-status:Show image details"
43 "show-image:Show properties of image"
44 "clone:Clone an image"
45 "rename:Rename an image"
46 "read-only:Mark or unmark image read-only"
47 "remove:Remove an image"
48
49 "pull-tar:Download a TAR container image"
50 "pull-raw:Download a RAW container or VM image"
51 "list-transfers:Show list of downloads in progress"
52 "cancel-transfer:Cancel a download"
53 )
54
55 if (( CURRENT == 1 )); then
56 _describe -t commands 'machinectl command' _machinectl_cmds || compadd "$@"
57 else
58 local curcontext="$curcontext"
59 cmd="${${_machinectl_cmds[(r)$words[1]:*]%%:*}}"
60 if (( $#cmd )); then
61 if (( CURRENT == 2 )); then
62 case $cmd in
63 list*|cancel-transfer|pull-tar|pull-raw)
64 msg="no options" ;;
65 clone)
66 _machinectl_machines ;;
67 start)
68 _machinectl_machines ;;
69 *)
70 _sd_machines
71 esac
72 else
73 case $cmd in
74 copy-to|copy-from|bind)
75 _files ;;
76 *) msg="no options"
77 esac
78 fi
79 else
80 _message "no more options"
81 fi
82 fi
83 }
84
85 _arguments \
86 {-h,--help}'[Prints a short help text and exits.]' \
87 '--version[Prints a short version string and exits.]' \
88 '--no-pager[Do not pipe output into a pager.]' \
89 '--no-legend[Do not show the headers and footers.]' \
90 '--no-ask-password[Do not ask for system passwords.]' \
91 {-H+,--host=}'[Operate on remote host.]:userathost:_sd_hosts_or_user_at_host' \
92 {-M+,--machine=}'[Operate on local container.]:machine:_sd_machines' \
93 {-p+,--property=}'[Limit output to specified property.]:property:(Name Id Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' \
94 {-a,--all}'[Show all properties.]' \
95 {-q,--quiet}'[Suppress output.]' \
96 {-l,--full}'[Do not ellipsize cgroup members.]' \
97 '--kill-who=[Who to send signal to.]:killwho:(leader all)' \
98 {-s+,--signal=}'[Which signal to send.]:signal:_signals' \
99 '--read-only[Create read-only bind mount.]' \
100 '--mkdir[Create directory before bind mounting, if missing.]' \
101 {-n+,--lines=}'[Number of journal entries to show.]:integer' \
102 {-o+,--output=}'[Change journal output mode.]:output modes:_sd_outputmodes' \
103 '--verify=[Verification mode for downloaded images.]:verify:(no checksum signature)' \
104 '--force[Download image even if already exists.]' \
105 '*::machinectl command:_machinectl_commands'