limenka-cli.footer.bash-completion raw

   1  
   2      case "$cur" in
   3          -conf=*)
   4              cur="${cur#*=}"
   5              _filedir
   6              return 0
   7              ;;
   8          -datadir=*)
   9              cur="${cur#*=}"
  10              _filedir -d
  11              return 0
  12              ;;
  13          -*=*)	# prevent nonsense completions
  14              return 0
  15              ;;
  16          *)
  17              local helpopts commands
  18  
  19              # only parse -help if senseful
  20              if [[ -z "$cur" || "$cur" =~ ^- ]]; then
  21                  helpopts=$($limenka_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
  22              fi
  23  
  24              # only parse help if senseful
  25              if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then
  26                  commands=$(_limenka_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }')
  27              fi
  28  
  29              COMPREPLY=( $( compgen -W "$helpopts $commands" -- "$cur" ) )
  30  
  31              # Prevent space if an argument is desired
  32              if [[ $COMPREPLY == *= ]]; then
  33                  compopt -o nospace
  34              fi
  35              return 0
  36              ;;
  37      esac
  38  } &&
  39  complete -F _limenka_cli limenka-cli
  40  
  41  # Local variables:
  42  # mode: shell-script
  43  # sh-basic-offset: 4
  44  # sh-indent-comment: t
  45  # indent-tabs-mode: nil
  46  # End:
  47  # ex: ts=4 sw=4 et filetype=sh
  48