Skip to content

Instantly share code, notes, and snippets.

@lengyijun
Created July 20, 2019 11:07
Show Gist options
  • Save lengyijun/71964f2dd819920cf30e12b47bee56a9 to your computer and use it in GitHub Desktop.
Save lengyijun/71964f2dd819920cf30e12b47bee56a9 to your computer and use it in GitHub Desktop.
#compdef gtool
typeset -A opt_args
_arguments -C \
'(- 1 *)--help[show usage]' \
'1: :->cmds'
case $state in
cmds)
_values \
'admin[Manage Fractal Node]::->admin' \
'block[Query Block]::->admin' \
'gstate[Manage Fractal Genesis State]' \
'keys[Manage Fractal Keys]' \
'state[Query Fractal State]' \
'tx[Generate Transaction]' \
'help[Shows a list of commands or help for one command]'
;;
esac
case $state in
admin)
_arguments \
'--rpc[value rpc service address]:value:' \
'--addr[value The address for keys]:value:' \
{--help,-h}'[show help]' \
':next arg:(( "info\:Show Fractal Node Info" "enode\:Show Fractal Node Enode Address" "genminingkey\:Generate Mining Key fro Current Address" ))'
# _describe 'command' admin_commands
;;
block)
local -a block_commands;
block_commands=('query:Query Block Detail')
_arguments \
'--rpc[value rpc service address]:value:' \
'--height[value block height (default: 0)]:value:' \
'--bhash[value block hash]:value:' \
{--help,-h}'[show help]'
_describe 'command' block_commands
;;
gstate)
local -a gstate_commands;
gstate_commands=('gen:Generate Fractal Genesis State Json')
_arguments \
'--pass[value The password for keys]:value:' \
'--gstake[value The total stake in genesis state (default: 1000000000000000)]:value:' \
{--help,-h}'[show help]'
_describe 'command' gstate_commands
;;
keys)
local -a keys_command;
keys_command=(
'list:List Fractal Keys'
'newkeys:New Keys for mining/packer/account'
'newminingkey:New Mining Key'
'newpackerkey:New Packer Key'
)
_arguments \
'--keys[value The Folder for all the key files]:value:_files' \
'--pass[value The password for keys]:value:' \
'--addr[value The address for keys]:value:' \
{--help,-h}'[show help]'
_describe 'command' keys_command
;;
state)
local -a state_command;
state_command=(
'account:Query account info'
'storage:Query storage info'
)
_arguments \
'--rpc[value rpc service address]:value:' \
'--addr[value The address for keys]:value:' \
'--table[value table name]:value:' \
'--skey[value storage key]:value:' \
{--help,-h}'[show help]'
_describe 'command' state_command
;;
tx)
local -a tx_command;
tx_command=(
'send:Send Transaction'
'batch:Batch Send Transaction'
'deploy:Deploy Contract'
'call:Call Contract'
)
_arguments \
'--rpc[value rpc service address]:value:' \
'--packer[value whether rpc server is packer or not]:value:' \
'--to[value to address]:value:' \
'--value[value transfer (default: 1)]:value:' \
'--tps[value tps for current test (default: 0)]:value:' \
'--nprocess[value process count (default: 0)]:value;' \
'--chainid[value chain id (default: 0)]:value:' \
'--keys[value The Folder for all the key files]:value:_files' \
'--pass[value The password for keys]:value:' \
'--wasm[value wasm file path]:value:_files -g "*.wasm"' \
'--abi[value abi file path]:filename:_files -g "*.abi"' \
'--action[value action name]:filename:' \
'--args[value args json]:value:' \
{--help,-h}'[show help]'
_describe 'command' tx_command
;;
help)
;;
esac
# '--verbosity[verbosity for log (default: 3)]:value:(1 2 3)' \
# '--help[show help]' \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment