#!/bin/bash

_lwr_factory_default_completions()
{
    local cur prev subcommands
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    subcommands="boot status schedule perform help"
    boot_subcommands="trigger init erase"

    if [[ ${COMP_CWORD} -eq 1 ]]; then
        COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) )
        return 0
    fi

    if [[ ${COMP_CWORD} -eq 2 ]]; then
        case "${prev}" in
            boot)
                COMPREPLY=( $(compgen -W "${boot_subcommands}" -- ${cur}) )
                return 0
                ;;
            *)
                COMPREPLY=()
                return 0
                ;;
        esac
    fi

    return 0
}

complete -F _lwr_factory_default_completions lwr-factory-default