core-lightning/contrib/lightning-cli.bash-completion
Rusty Russell ee303e4a94 contrib: fix up bash completion script.
$ lightning-cli <TAB><TAB>
autocleaninvoice               dev-slowcmd                    listinvoices
check                          dev-suppress-gossip            listnodes
close                          disconnect                     listpayments
connect                        feerates                       listpays
decodepay                      fundchannel                    listpeers
delexpiredinvoice              getinfo                        listsendpays
delinvoice                     getlog                         newaddr
dev-compact-gossip-store       getroute                       -o
dev-crash                      -h                             --order
dev-fail                       -H                             pay
dev-forget-channel             --help                         paystatus
dev-ignore-htlcs               help                           ping
dev-listaddrs                  --human-readable               --rpc-file
dev-memdump                    invoice                        sendpay
dev-memleak                    -J                             setchannelfee
dev-query-channel-range        --json                         stop
dev-query-scids                -k                             -V
dev-reenable-commit            --keywords                     --version
dev-rescan-outputs             --lightning-dir                waitanyinvoice
dev-rhash                      listchannels                   waitinvoice
dev-send-timestamp-filter      listconfigs                    waitsendpay
dev-set-max-scids-encode-size  listforwards                   withdraw
dev-sign-last-tx               listfunds

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-05-22 00:46:54 +00:00

49 lines
1.4 KiB
Bash

# bash programmable completion for lncli
# copy to /etc/bash_completion.d and restart your shell session
# Copyright (c) by Andreas M. Antonopoulos
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# modified by Tomas Stary (2018) for lightning-cli
_lightning_cli() {
local cur prev words=() cword
local lightning_cli
# lightning_cli might not be in $PATH
lightning_cli="$1"
COMPREPLY=()
_get_comp_words_by_ref -n = cur prev words cword
case "$cur" in
-*=*) # prevent nonsense completions
return 0
;;
*)
local helpopts globalcmds
# get the global options, starting with --
if [[ -z "$cur" || "$cur" =~ ^- ]]; then
globalcmds=$($lightning_cli --help 2>&1 | tr '|' '\n' | sed -n -e 's/ .*//' -e 's/\(-[-a-z0-9A-Z]*\).*/\1/p')
fi
# get the regular commands
if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then
helpopts=$($lightning_cli -H help 2>/dev/null | sed -n 's/^\([a-z][a-z-]*\).*/\1/p' | sed '$ d')
fi
COMPREPLY=( $( compgen -W "$helpopts $globalcmds" -X "*," -- "$cur" ) )
esac
} &&
complete -F _lightning_cli lightning-cli
# 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