2018-02-23 01:49:30 -08:00
package client
import "github.com/spf13/cobra"
2018-02-28 15:26:39 -08:00
// nolint
2018-02-23 01:49:30 -08:00
const (
2018-08-22 04:38:55 -07:00
DefaultGasAdjustment = 0
2018-06-28 17:54:47 -07:00
FlagUseLedger = "ledger"
2018-06-11 19:30:54 -07:00
FlagChainID = "chain-id"
FlagNode = "node"
FlagHeight = "height"
FlagGas = "gas"
2018-08-22 04:38:55 -07:00
FlagGasAdjustment = "gas-adjustment"
2018-06-11 19:30:54 -07:00
FlagTrustNode = "trust-node"
2018-07-05 17:07:03 -07:00
FlagFrom = "from"
2018-06-11 19:30:54 -07:00
FlagName = "name"
FlagAccountNumber = "account-number"
FlagSequence = "sequence"
2018-06-20 12:27:36 -07:00
FlagMemo = "memo"
2018-06-11 19:30:54 -07:00
FlagFee = "fee"
2018-07-05 19:15:35 -07:00
FlagAsync = "async"
2018-07-05 20:42:41 -07:00
FlagJson = "json"
2018-07-05 22:19:50 -07:00
FlagPrintResponse = "print-response"
2018-02-23 01:49:30 -08:00
)
2018-02-23 02:25:25 -08:00
// LineBreak can be included in a command list to provide a blank line
// to help with readability
var LineBreak = & cobra . Command { Run : func ( * cobra . Command , [ ] string ) { } }
2018-02-23 01:49:30 -08:00
// GetCommands adds common flags to query commands
func GetCommands ( cmds ... * cobra . Command ) [ ] * cobra . Command {
for _ , c := range cmds {
// TODO: make this default false when we support proofs
c . Flags ( ) . Bool ( FlagTrustNode , true , "Don't verify proofs for responses" )
2018-06-28 17:54:47 -07:00
c . Flags ( ) . Bool ( FlagUseLedger , false , "Use a connected Ledger device" )
2018-02-23 01:49:30 -08:00
c . Flags ( ) . String ( FlagChainID , "" , "Chain ID of tendermint node" )
2018-06-13 15:13:51 -07:00
c . Flags ( ) . String ( FlagNode , "tcp://localhost:26657" , "<host>:<port> to tendermint rpc interface for this chain" )
2018-02-23 01:49:30 -08:00
c . Flags ( ) . Int64 ( FlagHeight , 0 , "block height to query, omit to get most recent provable block" )
}
return cmds
}
// PostCommands adds common flags for commands to post tx
func PostCommands ( cmds ... * cobra . Command ) [ ] * cobra . Command {
for _ , c := range cmds {
2018-07-05 17:07:03 -07:00
c . Flags ( ) . String ( FlagFrom , "" , "Name of private key with which to sign" )
2018-06-11 19:30:54 -07:00
c . Flags ( ) . Int64 ( FlagAccountNumber , 0 , "AccountNumber number to sign the tx" )
2018-03-03 11:07:50 -08:00
c . Flags ( ) . Int64 ( FlagSequence , 0 , "Sequence number to sign the tx" )
2018-06-20 12:27:36 -07:00
c . Flags ( ) . String ( FlagMemo , "" , "Memo to send along with transaction" )
2018-03-03 11:07:50 -08:00
c . Flags ( ) . String ( FlagFee , "" , "Fee to pay along with transaction" )
2018-02-23 01:49:30 -08:00
c . Flags ( ) . String ( FlagChainID , "" , "Chain ID of tendermint node" )
2018-06-13 15:13:51 -07:00
c . Flags ( ) . String ( FlagNode , "tcp://localhost:26657" , "<host>:<port> to tendermint rpc interface for this chain" )
2018-06-28 17:54:47 -07:00
c . Flags ( ) . Bool ( FlagUseLedger , false , "Use a connected Ledger device" )
2018-08-22 04:38:55 -07:00
c . Flags ( ) . Int64 ( FlagGas , 0 , "gas limit to set per-transaction; set to 0 to calculate required gas automatically" )
2018-08-23 23:35:12 -07:00
c . Flags ( ) . Float64 ( FlagGasAdjustment , DefaultGasAdjustment , "adjustment factor to be multiplied against the estimate returned by the tx simulation; defaults to an internal value" )
2018-07-05 19:15:35 -07:00
c . Flags ( ) . Bool ( FlagAsync , false , "broadcast transactions asynchronously" )
2018-07-05 20:42:41 -07:00
c . Flags ( ) . Bool ( FlagJson , false , "return output in json format" )
2018-08-10 23:42:57 -07:00
c . Flags ( ) . Bool ( FlagPrintResponse , true , "return tx response (only works with async = false)" )
2018-02-23 01:49:30 -08:00
}
return cmds
}