~zethra/stargazer

26cfcd36777738bee75fb5b64f03ef8738c953d2 — Sashanoraa 19 days ago e74cfaf
Add back manually written shell completions

We don't have auto-generated ones anymore since we stopped using clap.

Signed-off-by: Sashanoraa <sasha@noraa.gay>
4 files changed, 81 insertions(+), 3 deletions(-)

A completions/stargazer.bash
A completions/stargazer.fish
A completions/stargazer.zsh
M scripts/install
A completions/stargazer.bash => completions/stargazer.bash +33 -0
@@ 0,0 1,33 @@
_stargazer() {
    local i cur opts cmds
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    cmd=""
    opts=""

    for i in ${COMP_WORDS[@]}
    do
        case "${i}" in
            stargazer)
                cmd="stargazer"
                ;;
            
            *)
                ;;
        esac
    done

    case "${cmd}" in
        stargazer)
            opts="-D -d -h -V  --debug --dev --check-config --help --version"
            if [[ ${cur} == -* ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            else
                COMPREPLY=($(compgen -f "${cur}"))
                return 0
            fi
    esac
}

complete -F _stargazer -o bashdefault -o default stargazer

A completions/stargazer.fish => completions/stargazer.fish +5 -0
@@ 0,0 1,5 @@
complete -c stargazer -n "__fish_use_subcommand" -s D -l debug -d 'Print debug information while server is running'
complete -c stargazer -n "__fish_use_subcommand" -s d -l dev -d 'Run server is dev mode. Servers out of current directory'
complete -c stargazer -n "__fish_use_subcommand" -l check-config -d 'Check config and exit'
complete -c stargazer -n "__fish_use_subcommand" -s h -l help -d 'Prints help information'
complete -c stargazer -n "__fish_use_subcommand" -s V -l version -d 'Prints version information'

A completions/stargazer.zsh => completions/stargazer.zsh +40 -0
@@ 0,0 1,40 @@
#compdef stargazer

autoload -U is-at-least

_stargazer() {
    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[@]}" \
'-D[Print debug information while server is running]' \
'--debug[Print debug information while server is running]' \
'-d[Run server is dev mode. Servers out of current directory]' \
'--dev[Run server is dev mode. Servers out of current directory]' \
'--check-config[Check config and exit]:file:_files' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'*:file:_files' \
&& ret=0
    
}

(( $+functions[_stargazer_commands] )) ||
_stargazer_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'stargazer commands' commands "$@"
}

_stargazer "$@"

M scripts/install => scripts/install +3 -3
@@ 62,10 62,10 @@ install -Dm644 ./config.ini "${DESTDIR}${SYSCONFDIR}/stargazer.ini"
install -Dm644 ./stargazer.1 "${DESTDIR}${MANDIR}/man1/stargazer.1"
install -Dm644 ./stargazer.ini.5 "${DESTDIR}${MANDIR}/man5/stargazer.ini.5"

install -D -m644 "./target/release/completions/stargazer.bash" \
install -D -m644 "./completions/stargazer.bash" \
				 "${BASHDIR}/stargazer"
install -D -m644 "./target/release/completions/_stargazer" \
install -D -m644 "./completions/stargazer.zsh" \
				 "${ZSHDIR}/_stargazer"
install -D -m644 "./target/release/completions/stargazer.fish" \
install -D -m644 "./completions/stargazer.fish" \
				 "${FISHDIR}/stargazer.fish"