#compdef kanidmd

autoload -U is-at-least

_kanidmd() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_kanidmd_commands" \
"*::: :->daemon" \
&& ret=0
    case $state in
    (daemon)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:kanidmd-command-$line[1]:"
        case $line[1] in
            (server)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(configtest)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(recover_account)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
':name -- The account name to recover credentials for:' \
&& ret=0
;;
(db_scan)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_kanidmd__db_scan_commands" \
"*::: :->db_scan" \
&& ret=0

    case $state in
    (db_scan)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:kanidmd-db_scan-command-$line[1]:"
        case $line[1] in
            (list_all_indexes)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(list_index)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
':index-name -- The name of the index to list:' \
&& ret=0
;;
(list_id2entry)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(get_id2entry)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
':id -- The id of the entry to display:' \
&& ret=0
;;
(list_index_analysis)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
        esac
    ;;
esac
;;
(database)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_kanidmd__database_commands" \
"*::: :->database" \
&& ret=0

    case $state in
    (database)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:kanidmd-database-command-$line[1]:"
        case $line[1] in
            (vacuum)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(backup)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
':path -- Output path for the backup content:' \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
':path -- Restore from this path. Should be created with "backup":' \
&& ret=0
;;
(verify)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(reindex)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
        esac
    ;;
esac
;;
(domain)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_kanidmd__domain_commands" \
"*::: :->domain" \
&& ret=0

    case $state in
    (domain)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:kanidmd-domain-command-$line[1]:"
        case $line[1] in
            (rename)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
        esac
    ;;
esac
;;
(healthcheck)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'*-n[Disable TLS verification]' \
'*--no-verify-tls[Disable TLS verification]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(version)
_arguments "${_arguments_options[@]}" \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]:CONFIG_PATH: ' \
'-o+[Log format (still in very early development)]:OUTPUT_MODE: ' \
'--output=[Log format (still in very early development)]:OUTPUT_MODE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_kanidmd_commands] )) ||
_kanidmd_commands() {
    local commands; commands=(
'server:Start the IDM Server' \
'configtest:Test the IDM Server configuration, without starting network listeners' \
'recover_account:Recover an account'\''s password' \
'db_scan:Inspect the internal content of the database datastructures' \
'database:Database maintenance, backups, restoration etc' \
'domain:Change domain settings' \
'healthcheck:Load the server config and check services are listening' \
'version:Print the program version and exit' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'kanidmd commands' commands "$@"
}
(( $+functions[_kanidmd__database__backup_commands] )) ||
_kanidmd__database__backup_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd database backup commands' commands "$@"
}
(( $+functions[_kanidmd__configtest_commands] )) ||
_kanidmd__configtest_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd configtest commands' commands "$@"
}
(( $+functions[_kanidmd__database_commands] )) ||
_kanidmd__database_commands() {
    local commands; commands=(
'vacuum:Vacuum the database to reclaim space or change db_fs_type/page_size (offline)' \
'backup:Backup the database content (offline)' \
'restore:Restore the database content (offline)' \
'verify:Verify database and entity consistency' \
'reindex:Reindex the database (offline)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'kanidmd database commands' commands "$@"
}
(( $+functions[_kanidmd__db_scan_commands] )) ||
_kanidmd__db_scan_commands() {
    local commands; commands=(
'list_all_indexes:List all index tables that exist on the system' \
'list_index:List all content of a named index' \
'list_id2entry:List all id2entry values with reduced entry content' \
'get_id2entry:View the data of a specific entry from id2entry' \
'list_index_analysis:List all content of index analysis' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'kanidmd db_scan commands' commands "$@"
}
(( $+functions[_kanidmd__domain_commands] )) ||
_kanidmd__domain_commands() {
    local commands; commands=(
'rename:Change the IDM domain name' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'kanidmd domain commands' commands "$@"
}
(( $+functions[_kanidmd__db_scan__get_id2entry_commands] )) ||
_kanidmd__db_scan__get_id2entry_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd db_scan get_id2entry commands' commands "$@"
}
(( $+functions[_kanidmd__healthcheck_commands] )) ||
_kanidmd__healthcheck_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd healthcheck commands' commands "$@"
}
(( $+functions[_kanidmd__database__help_commands] )) ||
_kanidmd__database__help_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd database help commands' commands "$@"
}
(( $+functions[_kanidmd__db_scan__help_commands] )) ||
_kanidmd__db_scan__help_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd db_scan help commands' commands "$@"
}
(( $+functions[_kanidmd__domain__help_commands] )) ||
_kanidmd__domain__help_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd domain help commands' commands "$@"
}
(( $+functions[_kanidmd__help_commands] )) ||
_kanidmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd help commands' commands "$@"
}
(( $+functions[_kanidmd__db_scan__list_all_indexes_commands] )) ||
_kanidmd__db_scan__list_all_indexes_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd db_scan list_all_indexes commands' commands "$@"
}
(( $+functions[_kanidmd__db_scan__list_id2entry_commands] )) ||
_kanidmd__db_scan__list_id2entry_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd db_scan list_id2entry commands' commands "$@"
}
(( $+functions[_kanidmd__db_scan__list_index_commands] )) ||
_kanidmd__db_scan__list_index_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd db_scan list_index commands' commands "$@"
}
(( $+functions[_kanidmd__db_scan__list_index_analysis_commands] )) ||
_kanidmd__db_scan__list_index_analysis_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd db_scan list_index_analysis commands' commands "$@"
}
(( $+functions[_kanidmd__recover_account_commands] )) ||
_kanidmd__recover_account_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd recover_account commands' commands "$@"
}
(( $+functions[_kanidmd__database__reindex_commands] )) ||
_kanidmd__database__reindex_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd database reindex commands' commands "$@"
}
(( $+functions[_kanidmd__domain__rename_commands] )) ||
_kanidmd__domain__rename_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd domain rename commands' commands "$@"
}
(( $+functions[_kanidmd__database__restore_commands] )) ||
_kanidmd__database__restore_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd database restore commands' commands "$@"
}
(( $+functions[_kanidmd__server_commands] )) ||
_kanidmd__server_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd server commands' commands "$@"
}
(( $+functions[_kanidmd__database__vacuum_commands] )) ||
_kanidmd__database__vacuum_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd database vacuum commands' commands "$@"
}
(( $+functions[_kanidmd__database__verify_commands] )) ||
_kanidmd__database__verify_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd database verify commands' commands "$@"
}
(( $+functions[_kanidmd__version_commands] )) ||
_kanidmd__version_commands() {
    local commands; commands=()
    _describe -t commands 'kanidmd version commands' commands "$@"
}

_kanidmd "$@"
