#!/usr/bin/env bash

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

    case "${prev}" in
        elegant|git-elegant)
            opts=($(git elegant commands))
            COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cur}) )
            return 0 ;;
        pull|epull)
            local data=$(git branch | awk -F ' +' '! /\(no branch\)/ {print $2}')
            COMPREPLY=( $(compgen -W "${data}" ${cur}) )
            return 0 ;;
        accept-work)
            COMPREPLY=(
                $(compgen -W "$(git branch --remotes --list)" -- ${cur})
            )
            return 0 ;;
        *)
            return 0 ;;
    esac
}

complete -F _git_elegant git-elegant

#!/usr/bin/env bash

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

    case "${prev}" in
        elegant|git-elegant)
            opts=($(git elegant commands))
            COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cur}) )
            return 0 ;;
        pull|epull)
            local data=$(git branch | awk -F ' +' '! /\(no branch\)/ {print $2}')
            COMPREPLY=( $(compgen -W "${data}" ${cur}) )
            return 0 ;;
        accept-work|obtain-work)
            COMPREPLY=(
                $(compgen -W "$(git branch --remotes --list)" -- ${cur})
            )
            return 0 ;;
        *)
            return 0 ;;
    esac
}

complete -F _git_elegant git-elegant

Add Bash completion for `obtain-work` command
Add Bash completion for `obtain-work` command

`obtain-work` completion will propose fetched remote branches as the
candidates.
