-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsli-bash-completion.sh
53 lines (48 loc) · 1.96 KB
/
sli-bash-completion.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#
# Bash completion enhances usability with tab-complete commands and arguments.
#
_sli_completions() {
local cur prev commands chan_cmds fees_cmds tools wallet_cmds
local pkg_cmds packages daemons
COMPREPLY=() # Array for completion suggestions
cur="${COMP_WORDS[COMP_CWORD]}" # Current word being completed
prev="${COMP_WORDS[COMP_CWORD-1]}" # Previous word
# Main SLi commandssli
commands="init start stop restart show-config edit logs status version node-health sign connect disconnect peers chan fees"
chan_cmds="open close list"
fees_cmds="check set adjust bump"
wallet_cmds="init logs new send list-addresses balance invoice qr-invoice remove-qr pay-invoice"
tools="macaroon-hex gen-passwords node-backup node-restore node-extract security-check ping-amboss wallet"
pkgs_cmds="list install upgrade get-recipe clean-cache remove"
daemons="albyhub litd lnd loopd poold"
# Fetch installed and available packages dynamically (if possible)
packages="albyhub lit lnd loop pool lndconnect" # Static list; could parse $PKGS_LIST
# Top-level command completion
if [ "$COMP_CWORD" -eq 1 ]; then
COMPREPLY=($(compgen -W "$commands $tools $pkgs_cmds" -- "$cur"))
# Second-level completion based on first argument
elif [ "$COMP_CWORD" -eq 2 ]; then
case "$prev" in
init)
COMPREPLY=($(compgen -W "wallet lit lnd" -- "$cur")) ;;
start|stop|restart|logs|status)
COMPREPLY=($(compgen -W "$daemons" -- "$cur")) ;;
show-config|edit)
COMPREPLY=($(compgen -W "albyhub lit lnd sli" -- "$cur")) ;;
chan)
COMPREPLY=($(compgen -W "$chan_cmds" -- "$cur")) ;;
fees)
COMPREPLY=($(compgen -W "$fees_cmds" -- "$cur")) ;;
wa|wallet)
COMPREPLY=($(compgen -W "$wallet_cmds" -- "$cur")) ;;
install|remove)
COMPREPLY=($(compgen -W "$packages" -- "$cur")) ;;
macaroon-hex)
COMPREPLY=($(compgen -W "admin readonly invoice" -- "$cur")) ;;
esac
fi
return 0
}
# Register the completion function for 'sli'
complete -F _sli_completions sli