#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[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
":: :_kanidmd_commands" \
"*::: :->kanidm" \
&& ret=0
    case $state in
    (kanidm)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:kanidmd-command-$line[1]:"
        case $line[1] in
            (server)
_arguments "${_arguments_options[@]}" \
'-d+[Logging level. quiet, default, filter, verbose, perffull]' \
'--debug=[Logging level. quiet, default, filter, verbose, perffull]' \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
;;
(backup)
_arguments "${_arguments_options[@]}" \
'-d+[Logging level. quiet, default, filter, verbose, perffull]' \
'--debug=[Logging level. quiet, default, filter, verbose, perffull]' \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
':path -- Output path for the backup content:_files' \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" \
'-d+[Logging level. quiet, default, filter, verbose, perffull]' \
'--debug=[Logging level. quiet, default, filter, verbose, perffull]' \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
':path -- Restore from this path. Should be created with "backupu":_files' \
&& ret=0
;;
(verify)
_arguments "${_arguments_options[@]}" \
'-d+[Logging level. quiet, default, filter, verbose, perffull]' \
'--debug=[Logging level. quiet, default, filter, verbose, perffull]' \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
;;
(recover_account)
_arguments "${_arguments_options[@]}" \
'-n+[The account name to recover credentials for]' \
'-d+[Logging level. quiet, default, filter, verbose, perffull]' \
'--debug=[Logging level. quiet, default, filter, verbose, perffull]' \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
;;
(reindex)
_arguments "${_arguments_options[@]}" \
'-d+[Logging level. quiet, default, filter, verbose, perffull]' \
'--debug=[Logging level. quiet, default, filter, verbose, perffull]' \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
;;
(vacuum)
_arguments "${_arguments_options[@]}" \
'-d+[Logging level. quiet, default, filter, verbose, perffull]' \
'--debug=[Logging level. quiet, default, filter, verbose, perffull]' \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
;;
(domain_name_change)
_arguments "${_arguments_options[@]}" \
'-n+[The new domain name]' \
'-d+[Logging level. quiet, default, filter, verbose, perffull]' \
'--debug=[Logging level. quiet, default, filter, verbose, perffull]' \
'-c+[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'--config=[Path to the server'\''s configuration file. If it does not exist, it will be created]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_kanidmd_commands] )) ||
_kanidmd_commands() {
    local commands; commands=(
        "server:Start the IDM Server" \
"backup:Backup the database content (offline)" \
"restore:Restore the database content (offline)" \
"verify:Verify database and entity consistency" \
"recover_account:Recover an account's password" \
"reindex:Reindex the database (offline)" \
"vacuum:Vacuum the database to reclaim space or change db_fs_type/page_size (offline)" \
"domain_name_change:Change the IDM domain name" \
"help:Prints this message or the help of the given subcommand(s)" \
    )
    _describe -t commands 'kanidmd commands' commands "$@"
}
(( $+functions[_kanidmd__backup_commands] )) ||
_kanidmd__backup_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'kanidmd backup commands' commands "$@"
}
(( $+functions[_kanidmd__domain_name_change_commands] )) ||
_kanidmd__domain_name_change_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'kanidmd domain_name_change commands' commands "$@"
}
(( $+functions[_kanidmd__help_commands] )) ||
_kanidmd__help_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'kanidmd help commands' commands "$@"
}
(( $+functions[_kanidmd__recover_account_commands] )) ||
_kanidmd__recover_account_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'kanidmd recover_account commands' commands "$@"
}
(( $+functions[_kanidmd__reindex_commands] )) ||
_kanidmd__reindex_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'kanidmd reindex commands' commands "$@"
}
(( $+functions[_kanidmd__restore_commands] )) ||
_kanidmd__restore_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'kanidmd restore commands' commands "$@"
}
(( $+functions[_kanidmd__server_commands] )) ||
_kanidmd__server_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'kanidmd server commands' commands "$@"
}
(( $+functions[_kanidmd__vacuum_commands] )) ||
_kanidmd__vacuum_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'kanidmd vacuum commands' commands "$@"
}
(( $+functions[_kanidmd__verify_commands] )) ||
_kanidmd__verify_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'kanidmd verify commands' commands "$@"
}

_kanidmd "$@"