# bash programmable completion for hushd(1) # Copyright (c) 2012-2017 The Bitcoin Core developers # Copyright (c) 2016-2017 The Zcash developers # Copyright (c) 2018 The Hush developers # Distributed under the GPLv3 software license, see the accompanying # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html _hushd() { local cur prev words=() cword local hushd # save and use original argument to invoke hushd for -help # it might not be in $PATH hushd="$1" COMPREPLY=() _get_comp_words_by_ref -n = cur prev words cword case "$cur" in -conf=*|-pid=*|-loadblock=*|-rpccookiefile=*|-wallet=*) cur="${cur#*=}" _filedir return 0 ;; -datadir=*|-exportdir=*) cur="${cur#*=}" _filedir -d return 0 ;; -*=*) # prevent nonsense completions return 0 ;; *) # only parse -help if senseful if [[ -z "$cur" || "$cur" =~ ^- ]]; then local helpopts helpopts=$($hushd -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' ) COMPREPLY=( $( compgen -W "$helpopts" -- "$cur" ) ) fi # Prevent space if an argument is desired if [[ $COMPREPLY == *= ]]; then compopt -o nospace fi return 0 ;; esac } && complete -F _hushd hushd # Local variables: # mode: shell-script # sh-basic-offset: 4 # sh-indent-comment: t # indent-tabs-mode: nil # End: # ex: ts=4 sw=4 et filetype=sh