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