limenka-cli.bash raw

   1  # Dynamic bash programmable completion for limenka-cli(1)
   2  #     DO NOT EDIT THIS FILE BY HAND -- THIS WILL FAIL THE FUNCTIONAL TEST tool_cli_completion
   3  # This file is auto-generated by the functional test tool_cli_completion.
   4  # If you want to modify this file, modify test/functional/tool_cli_completion.py and re-autogenerate
   5  # this file via the --overwrite test flag.
   6  
   7  # Copyright (c) 2012-2024 The Limenka developers
   8  # Distributed under the MIT software license, see the accompanying
   9  # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  10  
  11  # call $limenka-cli for RPC
  12  _limenka_rpc() {
  13      # determine already specified args necessary for RPC
  14      local rpcargs=()
  15      for i in ${COMP_LINE}; do
  16          case "$i" in
  17              -conf=*|-datadir=*|-regtest|-rpc*|-testnet|-testnet4)
  18                  rpcargs=( "${rpcargs[@]}" "$i" )
  19                  ;;
  20          esac
  21      done
  22      $limenka_cli "${rpcargs[@]}" "$@"
  23  }
  24  
  25  _limenka_cli() {
  26      local cur prev words=() cword
  27      local limenka_cli
  28  
  29      # save and use original argument to invoke limenka-cli for -help, help and RPC
  30      # as limenka-cli might not be in $PATH
  31      limenka_cli="$1"
  32  
  33      COMPREPLY=()
  34      _get_comp_words_by_ref -n = cur prev words cword
  35  
  36      if ((cword > 5)); then
  37          case ${words[cword-5]} in
  38              descriptorprocesspsbt)
  39                  COMPREPLY=( $( compgen -W "false true" -- "$cur" ) )
  40                  return 0
  41                  ;;
  42          esac
  43      fi
  44  
  45      if ((cword > 4)); then
  46          case ${words[cword-4]} in
  47              createpsbt|createrawtransaction|descriptorprocesspsbt|setban)
  48                  COMPREPLY=( $( compgen -W "false true" -- "$cur" ) )
  49                  return 0
  50                  ;;
  51              signrawtransactionwithkey)
  52                  COMPREPLY=( $( compgen -W "ALL ALL|ANYONECANPAY NONE NONE|ANYONECANPAY SINGLE SINGLE|ANYONECANPAY" -- "$cur" ) )
  53                  return 0
  54                  ;;
  55          esac
  56      fi
  57  
  58      if ((cword > 3)); then
  59          case ${words[cword-3]} in
  60              addnode|converttopsbt|getdescriptoractivity|gettxout|gettxoutsetinfo)
  61                  COMPREPLY=( $( compgen -W "false true" -- "$cur" ) )
  62                  return 0
  63                  ;;
  64          esac
  65      fi
  66  
  67      if ((cword > 2)); then
  68          case ${words[cword-2]} in
  69              converttopsbt|decoderawtransaction|finalizepsbt|getblockheader|getmempoolancestors|getmempooldescendants|getrawmempool|listmempooltransactions)
  70                  COMPREPLY=( $( compgen -W "false true" -- "$cur" ) )
  71                  return 0
  72                  ;;
  73              addnode)
  74                  COMPREPLY=( $( compgen -W "add onetry remove" -- "$cur" ) )
  75                  return 0
  76                  ;;
  77              setban)
  78                  COMPREPLY=( $( compgen -W "add remove" -- "$cur" ) )
  79                  return 0
  80                  ;;
  81              estimatesmartfee)
  82                  COMPREPLY=( $( compgen -W "CONSERVATIVE ECONOMICAL UNSET" -- "$cur" ) )
  83                  return 0
  84                  ;;
  85          esac
  86      fi
  87  
  88      case "$prev" in
  89          dumptxoutset|importmempool|loadtxoutset)
  90              _filedir
  91              return 0
  92              ;;
  93          getrawmempool|setnetworkactive|setscriptthreadsenabled)
  94              COMPREPLY=( $( compgen -W "false true" -- "$cur" ) )
  95              return 0
  96              ;;
  97      esac
  98  
  99      case "$cur" in
 100          -conf=*)
 101              cur="${cur#*=}"
 102              _filedir
 103              return 0
 104              ;;
 105          -datadir=*)
 106              cur="${cur#*=}"
 107              _filedir -d
 108              return 0
 109              ;;
 110          -*=*)	# prevent nonsense completions
 111              return 0
 112              ;;
 113          *)
 114              local helpopts commands
 115  
 116              # only parse -help if senseful
 117              if [[ -z "$cur" || "$cur" =~ ^- ]]; then
 118                  helpopts=$($limenka_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
 119              fi
 120  
 121              # only parse help if senseful
 122              if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then
 123                  commands=$(_limenka_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }')
 124              fi
 125  
 126              COMPREPLY=( $( compgen -W "$helpopts $commands" -- "$cur" ) )
 127  
 128              # Prevent space if an argument is desired
 129              if [[ $COMPREPLY == *= ]]; then
 130                  compopt -o nospace
 131              fi
 132              return 0
 133              ;;
 134      esac
 135  } &&
 136  complete -F _limenka_cli limenka-cli
 137  
 138  # Local variables:
 139  # mode: shell-script
 140  # sh-basic-offset: 4
 141  # sh-indent-comment: t
 142  # indent-tabs-mode: nil
 143  # End:
 144  # ex: ts=4 sw=4 et filetype=sh
 145