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