|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
From 9ca241de9a5c772044540e46366236a5fc8510b5 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
From: Lukas Rusak <lorusak@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
Date: Wed, 22 Apr 2015 15:52:59 -0700
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
Subject: [PATCH] zsh-completion: add missing completions for machinectl
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
Appologies, I'm still getting used to this mailing list thing and using git send-email
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
(cherry picked from commit b3b9282d0c79b108ed87abff5de6891617fe0602)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
shell-completion/zsh/_machinectl | 84 +++++++++++++++++++++++++++++++++-------
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
1 file changed, 70 insertions(+), 14 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
diff --git a/shell-completion/zsh/_machinectl b/shell-completion/zsh/_machinectl
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
index c666b7eb43..7898d7c05b 100644
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
--- a/shell-completion/zsh/_machinectl
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+++ b/shell-completion/zsh/_machinectl
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
@@ -1,5 +1,20 @@
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
#compdef machinectl
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+__get_available_machines () {
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ machinectl --no-legend list-images | {while read -r a b; do echo $a; done;}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+_available_machines() {
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ local -a _machines
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _machines=("${(fo)$(__get_available_machines)}")
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ typeset -U _machines
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ if [[ -n "$_machines" ]]; then
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _describe 'machines' _machines
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ else
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _message 'no machines'
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ fi
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
(( $+functions[_machinectl_command] )) || _machinectl_command()
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
{
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
local -a _machinectl_cmds
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
@@ -7,23 +22,55 @@
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
"list:List currently running VMs/containers"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
"status:Show VM/container status"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
"show:Show properties of one or more VMs/containers"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "start:Start container as a service"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
"login:Get a login prompt on a VM/container"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "enable:Enable automatic container start at boot"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "disable:Disable automatic container start at boot"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
"poweroff:Power off one or more VMs/containers"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
"reboot:Reboot one or more VMs/containers"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
"terminate:Terminate one or more VMs/containers"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
"kill:Send signal to process or a VM/container"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "copy-to:Copy files from the host to a container"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "copy-from:Copy files from a container to the host"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "bind:Bind mount a path from the host into a container"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "list-images:Show available container and VM images"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "image-status:Show image details"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "show-image:Show properties of image"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "clone:Clone an image"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "rename:Rename an image"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "read-only:Mark or unmark image read-only"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "remove:Remove an image"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "pull-tar:Download a TAR container image"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "pull-raw:Download a RAW container or VM image"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "pull-dkr:Download a DKR container image"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "list-transfers:Show list of downloads in progress"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ "cancel-transfer:Cancel a download"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
if (( CURRENT == 1 )); then
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_describe -t commands 'machinectl command' _machinectl_cmds || compadd "$@"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
else
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
local curcontext="$curcontext"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
cmd="${${_machinectl_cmds[(r)$words[1]:*]%%:*}}"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
if (( $#cmd )); then
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- case $cmd in
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- list) msg="no options" ;;
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- *)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- _sd_machines
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- esac
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ if (( CURRENT == 2 )); then
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ case $cmd in
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ list*|cancel-transfer|pull-tar|pull-raw|pull-dkr)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ msg="no options" ;;
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ start)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _available_machines ;;
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ *)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _sd_machines
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ esac
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ else
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ case $cmd in
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ copy-to|copy-from|bind)
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ _files ;;
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ *) msg="no options"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ esac
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ fi
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
else
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_message "no more options"
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
fi
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
@@ -33,13 +80,22 @@
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
_arguments \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
{-h,--help}'[Prints a short help text and exits.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
'--version[Prints a short version string and exits.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- \*{-p+,--property=}'[Limit output to specified property.]:property:(Name Id Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- {-a,--all}'[Show all proerties]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- (-l,--full)'[Do not ellipsize cgroup members]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- '--no-pager[Do not pipe output into a pager]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- '--no-ask-password[Do not ask for system passwords]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- '--kill-who=[Who to send signal to]:killwho:(leader all)' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- {-s+,--signal=}'[Which signal to send]:signal:_signals' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
- {-P,--privileged}'[Acquire privileges before execution]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ '--no-pager[Do not pipe output into a pager.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ '--no-legend[Do not show the headers and footers.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ '--no-ask-password[Do not ask for system passwords.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ {-H+,--host=}'[Operate on remote host.]:userathost:_sd_hosts_or_user_at_host' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ {-M+,--machine=}'[Operate on local container.]:machine:_sd_machines' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ {-p+,--property=}'[Limit output to specified property.]:property:(Name Id Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ {-a,--all}'[Show all proerties.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ {-q,--quiet}'[Suppress output.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ {-l,--full}'[Do not ellipsize cgroup members.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ '--kill-who=[Who to send signal to.]:killwho:(leader all)' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ {-s+,--signal=}'[Which signal to send.]:signal:_signals' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ '--read-only[Create read-only bind mount.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ '--mkdir[Create directory before bind mounting, if missing.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ {-n+,--lines=}'[Number of journal entries to show.]:integer' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ {-o+,--output=}'[Change journal output mode.]:output modes:_sd_outputmodes' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ '--verify=[Verification mode for downloaded images.]:verify:(no checksum signature)' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ '--force[Download image even if already exists.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
+ '--dkr-index-url=[Specify the index URL to use for DKR image downloads.]' \
|
|
Zbigniew Jędrzejewski-Szmek |
a48f80 |
'*::machinectl command:_machinectl_command'
|