_cloudkitty()
{
  local cur prev words
  COMPREPLY=()
  _get_comp_words_by_ref -n : cur prev words

  # Command data:
  cmds='collector collector-mapping complete dataframes hashmap help info module pyscript report scope summary tasks'
  cmds_collector='disable enable state'
  cmds_collector_mapping='create delete get list'
  cmds_collector_mapping_create='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_collector_mapping_delete='-h --help'
  cmds_collector_mapping_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_collector_mapping_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending --collector'
  cmds_collector_disable='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_collector_enable='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_collector_state='get'
  cmds_collector_state_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_complete='-h --help --name --shell'
  cmds_dataframes='add get'
  cmds_dataframes_add='-h --help'
  cmds_dataframes_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending --offset --limit --filter -b --begin -e --end'
  cmds_hashmap='field group mapping mapping-types service threshold'
  cmds_hashmap_field='create delete get list'
  cmds_hashmap_field_create='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_field_delete='-h --help'
  cmds_hashmap_field_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_field_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_group='create delete list mappings thresholds'
  cmds_hashmap_group_create='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_group_delete='-h --help --recursive'
  cmds_hashmap_group_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_group_mappings='get'
  cmds_hashmap_group_mappings_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_group_thresholds='get'
  cmds_hashmap_group_thresholds_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_mapping='create delete get list update'
  cmds_hashmap_mapping_types='list'
  cmds_hashmap_mapping_types_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_mapping_create='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending -s --service-id -g --group-id --field-id -p --project-id -t --type --value --name --start --end --description'
  cmds_hashmap_mapping_delete='-h --help'
  cmds_hashmap_mapping_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_mapping_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending -s --service-id -g --group-id --field-id -p --project-id --filter-tenant --no-group'
  cmds_hashmap_mapping_update='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending -s --service-id -g --group-id --field-id -p --project-id --value --cost --name --start --end --description'
  cmds_hashmap_service='create delete get list'
  cmds_hashmap_service_create='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_service_delete='-h --help'
  cmds_hashmap_service_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_service_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_threshold='create delete get list update'
  cmds_hashmap_threshold_create='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending -s --service-id -g --group-id --field-id -p --project-id -t --type'
  cmds_hashmap_threshold_delete='-h --help'
  cmds_hashmap_threshold_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_hashmap_threshold_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending -s --service-id -g --group-id --field-id -p --project-id --filter-tenant --no-group'
  cmds_hashmap_threshold_update='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending -s --service-id -g --group-id --field-id -p --project-id -l --level --cost'
  cmds_help='-h --help'
  cmds_info='config metric'
  cmds_info_config='get'
  cmds_info_config_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_info_metric='get list'
  cmds_info_metric_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_info_metric_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_module='disable enable get list set'
  cmds_module_disable='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_module_enable='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_module_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_module_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_module_set='priority'
  cmds_module_set_priority='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_pyscript='create delete get list update'
  cmds_pyscript_create='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending --start --end --description'
  cmds_pyscript_delete='-h --help'
  cmds_pyscript_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending'
  cmds_pyscript_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending -n --no-data'
  cmds_pyscript_update='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending -n --name -d --data --start --end --description'
  cmds_report='tenant'
  cmds_report_tenant='list'
  cmds_report_tenant_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending -b --begin -e --end'
  cmds_scope='patch state'
  cmds_scope_patch='-h --help --scope-key --collector --fetcher --active -id --scope-id'
  cmds_scope_state='get reset'
  cmds_scope_state_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending --scope-id --scope-key --collector --fetcher --offset --limit'
  cmds_scope_state_reset='-h --help --scope-id --scope-key --collector --fetcher -a --all-scopes'
  cmds_summary='get'
  cmds_summary_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending --offset --limit -g --groupby --filter -b --begin -e --end'
  cmds_tasks='reprocessing'
  cmds_tasks_reprocessing='create get'
  cmds_tasks_reprocessing_create='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending --scope-id --start-reprocess-time --end-reprocess-time --reason'
  cmds_tasks_reprocessing_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --sort-ascending --sort-descending --scope-id --offset --limit --order'

  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 _cloudkitty cloudkitty
