Sha256: 1f07bcbbc0fd20071d7a1756c8642974ed1c6e523009c0f452782238dacfb30b

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

#!/bin/bash

# cloudstack-cli
# https://github.com/niwo/cloudstack-cli
#
# Copyright (c) 2014 Nik Wolfgramm
# Licensed under the MIT license.
# https://raw.github.com/niwo/cloudstack-cli/master/LICENSE.txt

# Usage:
#
# To enable bash <tab> completion for cloudstack-cli, add the following line (minus the
# leading #, which is the bash comment character) to your ~/.bash_profile file (use ~/.bashrc on Ubuntu):
#
# eval "$(cs completion --shell=bash)"

_cs() {
  COMPREPLY=()
  local word="${COMP_WORDS[COMP_CWORD]}"
  if [ "$COMP_CWORD" -eq 1 ]; then
    COMPREPLY=( $(compgen -W "$(cs help | grep cs | cut -d ' ' -f4)" -- "$word") )
  else
    local words=("${COMP_WORDS[@]}")
    if [ $(echo ${words[@]} | wc -w) -eq 2 ]; then
      COMPREPLY=( $(compgen -W "$(${words[@]} help | grep cs | cut -d ' ' -f5)" -- "$word") )
    fi
    if [ $(echo ${words[@]} | wc -w) -ge 3 ]; then
      local cp1=$(echo ${words[@]} | cut -d ' ' -f1-2)
      local cp2=$(echo ${words[@]} | cut -d ' ' -f3)
      if [ "$cp2" != "help" ]; then
        local cp3=$($cp1 help $cp2)
        COMPREPLY=( $(compgen -W "$(echo $cp3 | awk 'NR>1{print $1}' RS=[ FS='\=')" -- "$word") )
      fi
    fi
  fi
}

complete -F _cs cs

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloudstack-cli-0.8.0 completions/cs.bash