|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Command completion for token-snapshot |
| 3 | +# Generated by Clikt |
| 4 | + |
| 5 | +__skip_opt_eq() { |
| 6 | + # this takes advantage of the fact that bash functions can write to local |
| 7 | + # variables in their callers |
| 8 | + (( i = i + 1 )) |
| 9 | + if [[ "${COMP_WORDS[$i]}" == '=' ]]; then |
| 10 | + (( i = i + 1 )) |
| 11 | + fi |
| 12 | +} |
| 13 | + |
| 14 | +_token_snapshot() { |
| 15 | + local i=1 |
| 16 | + local in_param='' |
| 17 | + local fixed_arg_names=() |
| 18 | + local vararg_name='' |
| 19 | + local can_parse_options=1 |
| 20 | + |
| 21 | + while [[ ${i} -lt $COMP_CWORD ]]; do |
| 22 | + if [[ ${can_parse_options} -eq 1 ]]; then |
| 23 | + case "${COMP_WORDS[$i]}" in |
| 24 | + --) |
| 25 | + can_parse_options=0 |
| 26 | + (( i = i + 1 )); |
| 27 | + continue |
| 28 | + ;; |
| 29 | + -n|--node-address) |
| 30 | + __skip_opt_eq |
| 31 | + (( i = i + 1 )) |
| 32 | + [[ ${i} -gt COMP_CWORD ]] && in_param='--node-address' || in_param='' |
| 33 | + continue |
| 34 | + ;; |
| 35 | + -c|--contract) |
| 36 | + __skip_opt_eq |
| 37 | + (( i = i + 1 )) |
| 38 | + [[ ${i} -gt COMP_CWORD ]] && in_param='--contract' || in_param='' |
| 39 | + continue |
| 40 | + ;; |
| 41 | + -f|--from) |
| 42 | + __skip_opt_eq |
| 43 | + (( i = i + 1 )) |
| 44 | + [[ ${i} -gt COMP_CWORD ]] && in_param='--from' || in_param='' |
| 45 | + continue |
| 46 | + ;; |
| 47 | + -t|--to) |
| 48 | + __skip_opt_eq |
| 49 | + (( i = i + 1 )) |
| 50 | + [[ ${i} -gt COMP_CWORD ]] && in_param='--to' || in_param='' |
| 51 | + continue |
| 52 | + ;; |
| 53 | + -o|--output) |
| 54 | + __skip_opt_eq |
| 55 | + (( i = i + 1 )) |
| 56 | + [[ ${i} -gt COMP_CWORD ]] && in_param='--output' || in_param='' |
| 57 | + continue |
| 58 | + ;; |
| 59 | + -m|--mode) |
| 60 | + __skip_opt_eq |
| 61 | + (( i = i + 1 )) |
| 62 | + [[ ${i} -gt COMP_CWORD ]] && in_param='--mode' || in_param='' |
| 63 | + continue |
| 64 | + ;; |
| 65 | + -h|--help) |
| 66 | + __skip_opt_eq |
| 67 | + in_param='' |
| 68 | + continue |
| 69 | + ;; |
| 70 | + esac |
| 71 | + fi |
| 72 | + case "${COMP_WORDS[$i]}" in |
| 73 | + *) |
| 74 | + (( i = i + 1 )) |
| 75 | + # drop the head of the array |
| 76 | + fixed_arg_names=("${fixed_arg_names[@]:1}") |
| 77 | + ;; |
| 78 | + esac |
| 79 | + done |
| 80 | + local word="${COMP_WORDS[$COMP_CWORD]}" |
| 81 | + if [[ "${word}" =~ ^[-] ]]; then |
| 82 | + COMPREPLY=($(compgen -W '-n --node-address -c --contract -f --from -t --to -o --output -m --mode -h --help' -- "${word}")) |
| 83 | + return |
| 84 | + fi |
| 85 | + |
| 86 | + # We're either at an option's value, or the first remaining fixed size |
| 87 | + # arg, or the vararg if there are no fixed args left |
| 88 | + [[ -z "${in_param}" ]] && in_param=${fixed_arg_names[0]} |
| 89 | + [[ -z "${in_param}" ]] && in_param=${vararg_name} |
| 90 | + |
| 91 | + case "${in_param}" in |
| 92 | + --node-address) |
| 93 | + ;; |
| 94 | + --contract) |
| 95 | + ;; |
| 96 | + --from) |
| 97 | + ;; |
| 98 | + --to) |
| 99 | + ;; |
| 100 | + --output) |
| 101 | + ;; |
| 102 | + --mode) |
| 103 | + ;; |
| 104 | + --help) |
| 105 | + ;; |
| 106 | + esac |
| 107 | +} |
| 108 | + |
| 109 | +complete -F _token_snapshot token-snapshot ./token-snapshot |
0 commit comments