Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-05-16 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Apr 22, 2015 at 03:52:59PM -0700, Lukas Rusak wrote:
 +_available_machines() {
 +local -a _machines
 +_machines=(${(fo)$(__get_available_machines)})
 +typeset -U _machines
 +if [[ -n $_machines ]]; then
 +_describe 'machines' _machines
 +else
 + _message 'no machines'
 +fi
^^^ you can see that indentation is borked here. No tabs please!
Hint: if you do 'git config --global color.ui auto', git diff
and similar will highlight tabs in red, making them easy to avoid.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-05-16 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Apr 22, 2015 at 03:52:59PM -0700, Lukas Rusak wrote:
 Appologies, I'm still getting used to this mailing list thing and using git 
 send-email
 
 ---
  shell-completion/zsh/_machinectl | 84 
 +---
  1 file changed, 70 insertions(+), 14 deletions(-)
 
 diff --git a/shell-completion/zsh/_machinectl 
 b/shell-completion/zsh/_machinectl
 index c666b7e..a81c5c7 100644
 --- a/shell-completion/zsh/_machinectl
 +++ b/shell-completion/zsh/_machinectl
 @@ -1,5 +1,20 @@
  #compdef machinectl
  
 +__get_available_machines () {
 +machinectl --no-legend list-images | awk '{print $1}' |  {while read -r 
 a b; do echo $a; done;}

I think this was supposed to be:

   machinectl --no-legend list-images | {while read -r a b; do echo $a; done;}

I fixed it up here and will push in a moment.

 +}
 +
 +_available_machines() {
 +local -a _machines
 +_machines=(${(fo)$(__get_available_machines)})
 +typeset -U _machines
 +if [[ -n $_machines ]]; then
 +_describe 'machines' _machines
 +else
 + _message 'no machines'
 +fi
 +}
 +
  (( $+functions[_machinectl_command] )) || _machinectl_command()
  {
local -a _machinectl_cmds
 @@ -7,23 +22,55 @@
  list:List currently running VMs/containers
  status:Show VM/container status
  show:Show properties of one or more VMs/containers
 +start:Start container as a service
  login:Get a login prompt on a VM/container
 +enable:Enable automatic container start at boot
 +disable:Disable automatic container start at boot
  poweroff:Power off one or more VMs/containers
  reboot:Reboot one or more VMs/containers
  terminate:Terminate one or more VMs/containers
  kill:Send signal to process or a VM/container
 +copy-to:Copy files from the host to a container
 +copy-from:Copy files from a container to the host
 +bind:Bind mount a path from the host into a container
 +
 +list-images:Show available container and VM images
 +image-status:Show image details
 +show-image:Show properties of image
 +clone:Clone an image
 +rename:Rename an image
 +read-only:Mark or unmark image read-only
 +remove:Remove an image
 +
 +pull-tar:Download a TAR container image
 +pull-raw:Download a RAW container or VM image
 +pull-dkr:Download a DKR container image
 +list-transfers:Show list of downloads in progress
 +cancel-transfer:Cancel a download
)
 +
if (( CURRENT == 1 )); then
  _describe -t commands 'machinectl command' _machinectl_cmds || compadd 
 $@
else
  local curcontext=$curcontext
  cmd=${${_machinectl_cmds[(r)$words[1]:*]%%:*}}
  if (( $#cmd )); then
 -  case $cmd in
 -list) msg=no options ;;
 -*)
 -  _sd_machines
 -  esac
 +  if (( CURRENT == 2 )); then
 +case $cmd in
 +  list*|cancel-transfer|pull-tar|pull-raw|pull-dkr)
 +msg=no options ;;
 +  start)
 +_available_machines ;;
 +  *)
 +_sd_machines
 +esac
 +  else
 +case $cmd in
 +  copy-to|copy-from|bind)
 +_files ;;
 +  *) msg=no options
 +esac
 +  fi
  else
_message no more options
  fi
 @@ -33,13 +80,22 @@
  _arguments \
{-h,--help}'[Prints a short help text and exits.]' \
'--version[Prints a short version string and exits.]' \
 -  \*{-p+,--property=}'[Limit output to specified property.]:property:(Name 
 Id Timestamp TimestampMonotonic Service Scope Leader Class State 
 RootDirectory)' \
 -  {-a,--all}'[Show all proerties]' \
 -  (-l,--full)'[Do not ellipsize cgroup members]' \
 -  '--no-pager[Do not pipe output into a pager]' \
 -  '--no-ask-password[Do not ask for system passwords]' \
 -  '--kill-who=[Who to send signal to]:killwho:(leader all)' \
 -  {-s+,--signal=}'[Which signal to send]:signal:_signals' \
 -  {-H+,--host=}'[Operate on remote 
 host]:userathost:_sd_hosts_or_user_at_host' \
 -  {-P,--privileged}'[Acquire privileges before execution]' \
 +  '--no-pager[Do not pipe output into a pager.]' \
 +  '--no-legend[Do not show the headers and footers.]' \
 +  '--no-ask-password[Do not ask for system passwords.]' \
 +  {-H+,--host=}'[Operate on remote 
 host.]:userathost:_sd_hosts_or_user_at_host' \
 +  {-M+,--machine=}'[Operate on local container.]:machine:_sd_machines' \
 +  {-p+,--property=}'[Limit output to specified property.]:property:(Name Id 
 Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' 
 \
 +  {-a,--all}'[Show all proerties.]' \
 +  {-q,--quiet}'[Suppress output.]' \
 +  {-l,--full}'[Do not ellipsize cgroup members.]' \
 +  '--kill-who=[Who to send signal to.]:killwho:(leader all)' \
 +  {-s+,--signal=}'[Which signal to send.]:signal:_signals' \
 +  '--read-only[Create read-only bind mount.]' \
 +  '--mkdir[Create directory before bind mounting, if missing.]' \
 +  {-n+,--lines=}'[Number of journal entries to 

Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-05-16 Thread Zbigniew Jędrzejewski-Szmek
On Mon, Apr 27, 2015 at 12:09:47PM -0700, Lukas Rusak wrote:
 I feel like this is already accomplished. The completion function
 _sd_machines already lists the running containers.
 
 Otherwise currently _available_machines is only used for machinectl
 start.
 see,
   list*|cancel-transfer|pull-tar|pull-raw|pull-dkr)
 msg=no options ;;
   start)
 _available_machines ;;
   *)
 _sd_machines
 
 All other functions (other than list-images, list-transfers, list,
 cancel-transfer, pull-tar, pull-raw, and pull-dkr) use the already
 implemented _sd_machines function to list currently running machines.
 
 So, if you would like I can change _available_machines to 
 _available_images
 and __get_available_machines to __get_available_images if this makes
 more sense.
Yes, please do that. Also change the hint to say 'images'/'no images'.
You'll have to do that as a separate commit: current patches are a big
improvement to existing completions, and this is a cosmetic fix, so
I'll push them now.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-27 Thread Lukas Rusak
I feel like this is already accomplished. The completion function
_sd_machines already lists the running containers.

Otherwise currently _available_machines is only used for machinectl
start.
see,
  list*|cancel-transfer|pull-tar|pull-raw|pull-dkr)
msg=no options ;;
  start)
_available_machines ;;
  *)
_sd_machines

All other functions (other than list-images, list-transfers, list,
cancel-transfer, pull-tar, pull-raw, and pull-dkr) use the already
implemented _sd_machines function to list currently running machines.

So, if you would like I can change _available_machines to _available_images
and __get_available_machines to __get_available_images if this makes
more sense.

On Thu, Apr 23, 2015 at 7:53 AM, Lennart Poettering lenn...@poettering.net
wrote:

 On Wed, 22.04.15 15:52, Lukas Rusak (loru...@gmail.com) wrote:

  Appologies, I'm still getting used to this mailing list thing and using
 git send-email
 
  ---
   shell-completion/zsh/_machinectl | 84
 +---
   1 file changed, 70 insertions(+), 14 deletions(-)
 
  diff --git a/shell-completion/zsh/_machinectl
 b/shell-completion/zsh/_machinectl
  index c666b7e..a81c5c7 100644
  --- a/shell-completion/zsh/_machinectl
  +++ b/shell-completion/zsh/_machinectl
  @@ -1,5 +1,20 @@
   #compdef machinectl
 
  +__get_available_machines () {
  +machinectl --no-legend list-images | awk '{print $1}' |  {while
 read -r a b; do echo $a; done;}
  +}
  +
  +_available_machines() {
  +local -a _machines
  +_machines=(${(fo)$(__get_available_machines)})
  +typeset -U _machines
  +if [[ -n $_machines ]]; then
  +_describe 'machines' _machines
  +else
  + _message 'no machines'
  +fi
  +}

 For this to be fully correct, you need to distuingish images and
 machines.

 Basically, machines are runtime objects, instances of containers
 currently running. images are files or directories on disk. You can
 run multiple machines off the same image (by use --read-only or
 --ephemeral).

 Other container/VM managers like libvirt-lxc also register their
 running containers with machined as machines, even though the backing
 images of those machines might not be visible to machined.

 Usually you run a machine from an image that carries the same name as
 the image, but that's not a requirement really.

 Some of machinectl's commands operate on images, others on running
 containers...

 Lennart

 --
 Lennart Poettering, Red Hat

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-23 Thread Lennart Poettering
On Wed, 22.04.15 15:52, Lukas Rusak (loru...@gmail.com) wrote:

 Appologies, I'm still getting used to this mailing list thing and using git 
 send-email
 
 ---
  shell-completion/zsh/_machinectl | 84 
 +---
  1 file changed, 70 insertions(+), 14 deletions(-)
 
 diff --git a/shell-completion/zsh/_machinectl 
 b/shell-completion/zsh/_machinectl
 index c666b7e..a81c5c7 100644
 --- a/shell-completion/zsh/_machinectl
 +++ b/shell-completion/zsh/_machinectl
 @@ -1,5 +1,20 @@
  #compdef machinectl
  
 +__get_available_machines () {
 +machinectl --no-legend list-images | awk '{print $1}' |  {while read -r 
 a b; do echo $a; done;}
 +}
 +
 +_available_machines() {
 +local -a _machines
 +_machines=(${(fo)$(__get_available_machines)})
 +typeset -U _machines
 +if [[ -n $_machines ]]; then
 +_describe 'machines' _machines
 +else
 + _message 'no machines'
 +fi
 +}

For this to be fully correct, you need to distuingish images and
machines.

Basically, machines are runtime objects, instances of containers
currently running. images are files or directories on disk. You can
run multiple machines off the same image (by use --read-only or
--ephemeral). 

Other container/VM managers like libvirt-lxc also register their
running containers with machined as machines, even though the backing
images of those machines might not be visible to machined.

Usually you run a machine from an image that carries the same name as
the image, but that's not a requirement really. 

Some of machinectl's commands operate on images, others on running
containers...

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-23 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Apr 23, 2015 at 04:44:01PM +0200, Lennart Poettering wrote:
 On Thu, 23.04.15 13:06, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote:
 
  On Wed, Apr 22, 2015 at 12:30:32PM -0700, Lukas Rusak wrote:
   Ah, completely missed images. So perhaps something like this would be
   better?
   
   machinectl --full --no-legend --no-pager list-images | awk '{print $1}'
  We usually try to avoid running external programs unless necessary. This
  can be implemented in pure shell which should be slightly faster.
 
 Well, it's not that easy, since machined actually searches multiple
 directories, ignores certain hidden files, drops .raw suffixes and
 suchlike. Of course, you can replicate all that in shell, or you can
 avoid it...
I was only talking about using awk to seperate the first word!

  I think you can ignore spaces for now. This is just tab completion after 
  all,
  it doesn't have to be bullet proof, and using spaces in image names would be
  fairly exotic.
 
 We don't support that in machined anyway.
Perfect.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-23 Thread Lennart Poettering
On Thu, 23.04.15 13:06, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote:

 On Wed, Apr 22, 2015 at 12:30:32PM -0700, Lukas Rusak wrote:
  Ah, completely missed images. So perhaps something like this would be
  better?
  
  machinectl --full --no-legend --no-pager list-images | awk '{print $1}'
 We usually try to avoid running external programs unless necessary. This
 can be implemented in pure shell which should be slightly faster.

Well, it's not that easy, since machined actually searches multiple
directories, ignores certain hidden files, drops .raw suffixes and
suchlike. Of course, you can replicate all that in shell, or you can
avoid it...

 I think you can ignore spaces for now. This is just tab completion after all,
 it doesn't have to be bullet proof, and using spaces in image names would be
 fairly exotic.

We don't support that in machined anyway.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-23 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Apr 22, 2015 at 12:30:32PM -0700, Lukas Rusak wrote:
 Ah, completely missed images. So perhaps something like this would be
 better?
 
 machinectl --full --no-legend --no-pager list-images | awk '{print $1}'
We usually try to avoid running external programs unless necessary. This
can be implemented in pure shell which should be slightly faster.

I think you can ignore spaces for now. This is just tab completion after all,
it doesn't have to be bullet proof, and using spaces in image names would be
fairly exotic.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-22 Thread Lukas Rusak
---
 shell-completion/zsh/_machinectl | 84 +---
 1 file changed, 70 insertions(+), 14 deletions(-)

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

___
systemd-devel mailing list

Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-22 Thread Lennart Poettering
On Wed, 22.04.15 11:07, Lukas Rusak (loru...@gmail.com) wrote:

 ---
  shell-completion/zsh/_machinectl | 84 
 +---
  1 file changed, 70 insertions(+), 14 deletions(-)
 
 diff --git a/shell-completion/zsh/_machinectl 
 b/shell-completion/zsh/_machinectl
 index c666b7e..2b1b7ed 100644
 --- a/shell-completion/zsh/_machinectl
 +++ b/shell-completion/zsh/_machinectl
 @@ -1,5 +1,20 @@
  #compdef machinectl
  
 +__get_available_machines () {
 +ls -1 /var/lib/container |  {while read -r a b; do echo $a; done;}
 +}

Hmm, the right way to list running containers is with machinectl
list. The right way to list container images is with machinectl
list-images.

Just listing /var/lib/container is not right, because the we tent to
prefer /var/lib/machines now, and because we support raw images in
those dirs, which carry the .raw suffix which should be removed when
used as machine name.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-22 Thread Lukas Rusak
Ah, completely missed images. So perhaps something like this would be
better?

machinectl --full --no-legend --no-pager list-images | awk '{print $1}'

as this lists

fedora
fedora-rawhide

instead of

fedora.raw
fedora-rawhide

However this will break if one has spaces in the container name. I would
delimit awk by a tab, but it seems list-images doesn't delimit by tabs. So
I'm not sure what the best solution would be as something like this, ls -1
/var/lib/container | sed 's|\.raw||g' seems kind of silly.

(Apologies for sending twice. I missed the CC)

On Wed, Apr 22, 2015 at 11:20 AM, Lennart Poettering lenn...@poettering.net
 wrote:

 On Wed, 22.04.15 11:07, Lukas Rusak (loru...@gmail.com) wrote:

  ---
   shell-completion/zsh/_machinectl | 84
 +---
   1 file changed, 70 insertions(+), 14 deletions(-)
 
  diff --git a/shell-completion/zsh/_machinectl
 b/shell-completion/zsh/_machinectl
  index c666b7e..2b1b7ed 100644
  --- a/shell-completion/zsh/_machinectl
  +++ b/shell-completion/zsh/_machinectl
  @@ -1,5 +1,20 @@
   #compdef machinectl
 
  +__get_available_machines () {
  +ls -1 /var/lib/container |  {while read -r a b; do echo $a; done;}
  +}

 Hmm, the right way to list running containers is with machinectl
 list. The right way to list container images is with machinectl
 list-images.

 Just listing /var/lib/container is not right, because the we tent to
 prefer /var/lib/machines now, and because we support raw images in
 those dirs, which carry the .raw suffix which should be removed when
 used as machine name.

 Lennart

 --
 Lennart Poettering, Red Hat

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-22 Thread Lennart Poettering
On Wed, 22.04.15 15:44, Lukas Rusak (loru...@gmail.com) wrote:

 Here is a rebase of the original patch to include the discussed changes

Where?

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-22 Thread Lukas Rusak
Appologies, I'm still getting used to this mailing list thing and using git 
send-email

---
 shell-completion/zsh/_machinectl | 84 +---
 1 file changed, 70 insertions(+), 14 deletions(-)

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

Re: [systemd-devel] [PATCH 1/3] zsh-completion: add missing completions for machinectl

2015-04-22 Thread Lukas Rusak
Here is a rebase of the original patch to include the discussed changes

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel