bitcoin-util.fish raw
1 # Disable files from being included in completions by default
2 complete --command bitcoin-util --no-files
3
4 # Extract options
5 function __fish_bitcoin_util_get_options
6 set --local cmd (commandline -opc)[1]
7 set --local options
8
9 set --append options ($cmd -help 2>&1 | string match -r '^ -.*' | string replace -r ' -' '-' | string replace -r '=.*' '=')
10
11 for option in $options
12 echo $option
13 end
14 end
15
16 # Extract commands
17 function __fish_bitcoin_util_get_commands
18 set --local cmd (commandline -opc)[1]
19 set --local commands
20
21 set --append commands ($cmd -help | sed -e '1,/Commands:/d' -e 's/=/=\t/' -e 's/(=/=/' -e '/^ [a-z]/ p' -e d | string replace -r '\ \ ' '')
22 for command in $commands
23 echo $command
24 end
25 end
26
27 # Add options
28 complete \
29 --command bitcoin-util \
30 --condition "not __fish_seen_subcommand_from (__fish_bitcoin_util_get_commands)" \
31 --arguments "(__fish_bitcoin_util_get_options)"
32
33 # Add commands
34 complete \
35 --command bitcoin-util \
36 --condition "not __fish_seen_subcommand_from (__fish_bitcoin_util_get_commands)" \
37 --arguments "(__fish_bitcoin_util_get_commands)"
38
39