File: vitrage.bash_completion

package info (click to toggle)
python-vitrageclient 5.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 648 kB
  • sloc: python: 1,807; makefile: 26; sh: 2
file content (81 lines) | stat: -rwxr-xr-x 4,389 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
_vitrage()
{
  local cur prev words
  COMPREPLY=()
  _get_comp_words_by_ref -n : cur prev words

  # Command data:
  cmds='alarm complete event healthcheck help rca resource service status template topology webhook'
  cmds_alarm='count history list show'
  cmds_alarm_count='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --all-tenants'
  cmds_alarm_history='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --all-tenants --limit --marker --start --end'
  cmds_alarm_list='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --all-tenants --limit --marker'
  cmds_alarm_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
  cmds_complete='-h --help --name --shell'
  cmds_event='post'
  cmds_event_post='-h --help --type --time --details'
  cmds_healthcheck='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
  cmds_help='-h --help'
  cmds_rca='show'
  cmds_rca_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --all-tenants'
  cmds_resource='count list show'
  cmds_resource_count='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --type --all-tenants --filter --group-by'
  cmds_resource_list='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --type --all-tenants --filter'
  cmds_resource_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
  cmds_service='list'
  cmds_service_list='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column'
  cmds_status='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
  cmds_template='add delete list show validate versions'
  cmds_template_add='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --path --type --params --wait --overwrite'
  cmds_template_delete='-h --help --wait'
  cmds_template_list='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column'
  cmds_template_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
  cmds_template_validate='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --path --type --params'
  cmds_template_versions='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column'
  cmds_topology='show'
  cmds_topology_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --filter --limit --root --graph-type --all-tenants'
  cmds_webhook='add delete list show'
  cmds_webhook_add='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --url --regex_filter --headers'
  cmds_webhook_delete='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
  cmds_webhook_list='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --all-tenants'
  cmds_webhook_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'

  dash=-
  underscore=_
  cmd=""
  words[0]=""
  completed="${cmds}"
  for var in "${words[@]:1}"
  do
    if [[ ${var} == -* ]] ; then
      break
    fi
    if [ -z "${cmd}" ] ; then
      proposed="${var}"
    else
      proposed="${cmd}_${var}"
    fi
    local i="cmds_${proposed}"
    i=${i//$dash/$underscore}
    local comp="${!i}"
    if [ -z "${comp}" ] ; then
      break
    fi
    if [[ ${comp} == -* ]] ; then
      if [[ ${cur} != -* ]] ; then
        completed=""
        break
      fi
    fi
    cmd="${proposed}"
    completed="${comp}"
  done

  if [ -z "${completed}" ] ; then
    COMPREPLY=( $( compgen -f -- "$cur" ) $( compgen -d -- "$cur" ) )
  else
    COMPREPLY=( $(compgen -W "${completed}" -- ${cur}) )
  fi
  return 0
}
complete -F _vitrage vitrage