bitcoind.fish raw

   1  # Disable files from being included in completions by default
   2  complete --command bitcoind --no-files
   3  
   4  # Extract options
   5  function __fish_bitcoind_get_options
   6      argparse 'nofiles' -- $argv
   7      set --local cmd (commandline -opc)[1]
   8      set --local options
   9  
  10      if set -q _flag_nofiles
  11          set --append options ($cmd -help-debug | string match -r '^  -.*' | string replace -r '  -' '-' | string replace -r '=.*' '=' | string match --invert -r '^.*=$')
  12      else
  13          set --append options ($cmd -help-debug | string match -r '^  -.*' | string replace -r '  -' '-' | string replace -r '=.*' '=' | string match -r '^.*=$')
  14      end
  15  
  16      for option in $options
  17          echo $option
  18      end
  19  end
  20  
  21  
  22  # Add options with file completion
  23  complete \
  24      --command bitcoind \
  25      --arguments "(__fish_bitcoind_get_options)"
  26  # Enable file completions only if the commandline now contains a `*.=` style option
  27  complete --command bitcoind \
  28      --condition 'string match --regex -- ".*=" (commandline -pt)' \
  29      --force-files
  30  
  31  # Add options without file completion
  32  complete \
  33      --command bitcoind \
  34      --arguments "(__fish_bitcoind_get_options --nofiles)"
  35  
  36