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