#compdef mbake

_mbake() {
    local -a commands options format_opts validate_opts 
shell_opts
    commands=(
        'format:Format Makefiles according to style rules'
        'validate:Validate Makefile syntax using GNU make'
        'init:Initialize configuration file with defaults'
        'config:Show current configuration'
        'update:Update mbake to the latest version'
        'completions:Generate shell completion scripts'
    )
    format_opts=(
        '--check[Check formatting rules without making 
changes]'
        '--diff[Show diff of changes that would be made]'
        '--backup[Create backup files before formatting]'
        '--validate[Validate syntax after formatting]'
        '--verbose[Enable verbose output]'
        '--config[Path to configuration file]'
        '--stdin[Read from stdin and write to stdout]'
    )
    validate_opts=(
        '--verbose[Enable verbose output]'
        '--config[Path to configuration file]'
    )
    shell_opts=(
        'bash:Generate Bash completion script'
        'zsh:Generate Zsh completion script'
        'fish:Generate Fish completion script'
    )

    _arguments -C         '--version[Show version and 
exit]'         '--help[Show help message and exit]'       
'1: :_describe "command" commands'         '*:: :->args'

    case $state in
        args)
            case $words[1] in
                format)
                    _arguments $format_opts
                    ;;
                validate)
                    _arguments $validate_opts
                    ;;
                completions)
                    _describe 'shell' shell_opts
                    ;;
            esac
            ;;
    esac
}

_mbake
