]>
Commit | Line | Data |
---|---|---|
439b7ce8 | 1 | #compdef machinectl |
7059062c | 2 | # SPDX-License-Identifier: LGPL-2.1+ |
439b7ce8 | 3 | |
c501ecd7 | 4 | (( $+functions[__machinectl_get_machines] )) || |
5 | __machinectl_get_machines () { | |
b3b9282d LR |
6 | machinectl --no-legend list-images | {while read -r a b; do echo $a; done;} |
7 | } | |
8 | ||
c501ecd7 | 9 | (( $+functions[_machinectl_machines] )) || |
10 | _machinectl_machines() { | |
b3b9282d | 11 | local -a _machines |
c501ecd7 | 12 | _machines=("${(fo)$(__machinectl_get_machines)}") |
b3b9282d LR |
13 | typeset -U _machines |
14 | if [[ -n "$_machines" ]]; then | |
15 | _describe 'machines' _machines | |
16 | else | |
17 | _message 'no machines' | |
18 | fi | |
19 | } | |
20 | ||
c501ecd7 | 21 | (( $+functions[_machinectl_commands] )) || _machinectl_commands() |
439b7ce8 WG |
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" | |
b3b9282d | 28 | "start:Start container as a service" |
b2bb19bb | 29 | "stop:Stop container (equal to poweroff)" |
4433c995 | 30 | "login:Get a login prompt on a VM/container" |
b3b9282d LR |
31 | "enable:Enable automatic container start at boot" |
32 | "disable:Disable automatic container start at boot" | |
4433c995 DM |
33 | "poweroff:Power off one or more VMs/containers" |
34 | "reboot:Reboot one or more VMs/containers" | |
439b7ce8 WG |
35 | "terminate:Terminate one or more VMs/containers" |
36 | "kill:Send signal to process or a VM/container" | |
b3b9282d LR |
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" | |
b3b9282d LR |
51 | "list-transfers:Show list of downloads in progress" |
52 | "cancel-transfer:Cancel a download" | |
439b7ce8 | 53 | ) |
b3b9282d | 54 | |
439b7ce8 WG |
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 | |
b3b9282d LR |
61 | if (( CURRENT == 2 )); then |
62 | case $cmd in | |
b43d75c3 | 63 | list*|cancel-transfer|pull-tar|pull-raw) |
b3b9282d | 64 | msg="no options" ;; |
ed251bf2 | 65 | clone) |
c501ecd7 | 66 | _machinectl_machines ;; |
b3b9282d | 67 | start) |
c501ecd7 | 68 | _machinectl_machines ;; |
b3b9282d LR |
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 | |
439b7ce8 WG |
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.]' \ | |
b3b9282d LR |
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)' \ | |
adb4c246 | 94 | {-a,--all}'[Show all properties.]' \ |
b3b9282d LR |
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.]' \ | |
c501ecd7 | 105 | '*::machinectl command:_machinectl_commands' |