Sha256: ec354377809ea3393be87efb1c272ea68cc89ee911bc16d4498a11ff35aaab88

Contents?: true

Size: 1.59 KB

Versions: 44

Compression:

Stored size: 1.59 KB

Contents

#!/bin/bash

# cloudstack-cli
# https://github.com/niwo/cloudstack-cli
#
# Copyright (c) 2015 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 "$(cloudstack-cli completion --shell=bash)"

_cloudstack_cli() {
  COMPREPLY=()
  local word="${COMP_WORDS[COMP_CWORD]}"
  # list available base commands
  if [ "$COMP_CWORD" -eq 1 ]; then
    COMPREPLY=( $(compgen -W "$(cloudstack-cli help | grep cloudstack-cli | cut -d ' ' -f4)" -- "$word") )
  else
    local words=("${COMP_WORDS[@]}")
    # ignore commands which contain 'help'
    if [[ "${words[@]}" == *help* ]]; then
      COMPREPLY=( $(compgen -W '' -- "$word") )
    # search for subcommand
    elif [[ "$word" != -* ]] && [ "$COMP_CWORD" -eq 2 ]; then
      local cp1=$(echo ${words[@]} | cut -d ' ' -f1-2)
      COMPREPLY=( $(compgen -W "$($cp1 help | grep cloudstack-cli | cut -d ' ' -f5)" -- "$word") )
    # list options for the subcommand
    elif [[ "$word" =~ -* ]] && [ "$COMP_CWORD" -gt 2 ]; then
      local cp1=$(echo ${words[@]} | cut -d ' ' -f1-2)
      local cp2=$(echo ${words[@]} | cut -d ' ' -f3)
      local cp3=$($cp1 help $cp2 2>/dev/null)
      COMPREPLY=( $(compgen -W "$(echo $cp3 | awk 'NR>1{print $1}' RS=[ FS='\=' 2>/dev/null)" -- "$word") )
    else
      COMPREPLY=()
    fi
    return 0
  fi
}

complete -o bashdefault -o default -F _cloudstack_cli cloudstack-cli cs

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
cloudstack-cli-1.6.10 completions/cloudstack-cli.bash
cloudstack-cli-1.6.9 completions/cloudstack-cli.bash
cloudstack-cli-1.6.8 completions/cloudstack-cli.bash
cloudstack-cli-1.6.7 completions/cloudstack-cli.bash
cloudstack-cli-1.6.6 completions/cloudstack-cli.bash
cloudstack-cli-1.6.5 completions/cloudstack-cli.bash
cloudstack-cli-1.6.4 completions/cloudstack-cli.bash
cloudstack-cli-1.6.3 completions/cloudstack-cli.bash
cloudstack-cli-1.6.2 completions/cloudstack-cli.bash
cloudstack-cli-1.6.1 completions/cloudstack-cli.bash
cloudstack-cli-1.6.0 completions/cloudstack-cli.bash
cloudstack-cli-1.5.13 completions/cloudstack-cli.bash
cloudstack-cli-1.5.12 completions/cloudstack-cli.bash
cloudstack-cli-1.5.10 completions/cloudstack-cli.bash
cloudstack-cli-1.5.9 completions/cloudstack-cli.bash
cloudstack-cli-1.5.8 completions/cloudstack-cli.bash
cloudstack-cli-1.5.7 completions/cloudstack-cli.bash
cloudstack-cli-1.5.6 completions/cloudstack-cli.bash
cloudstack-cli-1.5.5 completions/cloudstack-cli.bash
cloudstack-cli-1.5.4 completions/cloudstack-cli.bash