# bash completion for brctl (Cumulus Linux version)        -*- shell-script -*-

_brctl()
{
    local cur prev words cword
    _init_completion || return

    local command=${words[1]}

    case $cword in
        1)
            COMPREPLY=( $( compgen -W "addbr delbr addif delif setageing
                setbridgeprio setfd sethello setmaxage setpathcost setportprio
                show showmacs showstp stp sethashel sethashmax
                setmclmc setmcrouter setmcsnoop setmcsqc setmclmi setmcmi
                setmcqi setmcqifaddr setmcqpi setmcqri setmcquerier
                setmcsqi setportmcfl setportmcrouter delmcqv4src setmcqv4src
                showmcqv4src" -- "$cur" ) )
            ;;
        2)
            case $command in
                show)
                    ;;
                *)
                    COMPREPLY=( $( compgen -W "$(brctl show | \
                        grep 'yes\|no' | awk '{print $1}')" -- "$cur" ) )
            esac
            ;;
        3)
            case $command in
                addif|delif|setportmcrouter|setportmcfl)
                    COMPREPLY=( $( compgen -W "$(for x in \
                        `ls /sys/class/net/${words[2]}/brif/`; do echo $x; \
                        done)" -- "$cur" ) )
                    ;;
                stp)
                    COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
                    ;;
            esac
            ;;
    esac
} &&
complete -F _brctl -o default brctl

# ex: ts=4 sw=4 et filetype=sh
