_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 summary total'
  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'
  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'
  cmds_collector_mapping_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column --collector'
  cmds_collector_disable='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column'
  cmds_collector_enable='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column'
  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'
  cmds_complete='-h --help --name --shell'
  cmds_dataframes='get'
  cmds_dataframes_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column -b --begin -e --end -p --project-id -r --resource_type'
  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'
  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'
  cmds_hashmap_field_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column'
  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'
  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'
  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'
  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'
  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'
  cmds_hashmap_mapping_create='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column -s --service-id -g --group-id --field-id -p --project-id -t --type --value'
  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'
  cmds_hashmap_mapping_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column -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 -s --service-id -g --group-id --field-id -p --project-id --value --cost'
  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'
  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'
  cmds_hashmap_service_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column'
  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 -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'
  cmds_hashmap_threshold_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column -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 -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'
  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'
  cmds_info_metric_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column'
  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'
  cmds_module_enable='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column'
  cmds_module_get='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column'
  cmds_module_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column'
  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'
  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'
  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'
  cmds_pyscript_list='-h --help -f --format -c --column --format-config-file --quote --noindent --max-width --fit-width --print-empty --sort-column -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 -n --name -d --data'
  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 -b --begin -e --end'
  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 -t --tenant-id -b --begin -e --end -s --service -g --groupby -a --all-tenants'
  cmds_total='get'
  cmds_total_get='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty -t --tenant-id -b --begin -e --end -s --service -g --groupby -a --all-tenants'

  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
