Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ConsoleLog is logging for console. ConsoleLog *logrus.Logger // CqlCommands initialized in package main CqlCommands []*Command )
var CmdConsole = &Command{ UsageLine: "cql console [common params] [-command sqlcommand] [-out outputfile] [-no-rc true/false] [-single-transaction] [-variable variables] [-explorer explorer_addr] [dsn]", Short: "run a console for interactive sql operation", Long: ` Console runs an interactive SQL console for CQL. e.g. cql console cql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c There is also a -command param for SQL script, and you can add "< file.sql" at end of command for executing a SQL file. If those params are set, it will run SQL script and exit without staying console mode. e.g. cql console -command "create table test1(test2 int);" cql://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c `, Flag: flag.NewFlagSet("Console params", flag.ExitOnError), CommonFlag: flag.NewFlagSet("Common params", flag.ExitOnError), DebugFlag: flag.NewFlagSet("Debug params", flag.ExitOnError), }
CmdConsole is cql console command entity.
var CmdCreate = &Command{ UsageLine: "cql create [common params] [-wait-tx-confirm] [db_meta_params]", Short: "create a database", Long: ` Create command creates a CQL database by database meta params. The meta info must include node count. e.g. cql create -db-node 2 Since CQL is built on top of blockchains, you may want to wait for the transaction confirmation before the creation takes effect. e.g. cql create -wait-tx-confirm -db-node 2 `, Flag: flag.NewFlagSet("DB meta params", flag.ExitOnError), CommonFlag: flag.NewFlagSet("Common params", flag.ExitOnError), DebugFlag: flag.NewFlagSet("Debug params", flag.ExitOnError), }
CmdCreate is cql create command entity.
var CmdDrop = &Command{ UsageLine: "cql drop [common params] [-wait-tx-confirm] dsn", Short: "drop a database by dsn or database id", Long: ` Drop drops a CQL database by DSN or database ID. e.g. cql drop cqlprotocol://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c Since CQL is built on top of blockchains, you may want to wait for the transaction confirmation before the drop operation takes effect. e.g. cql drop -wait-tx-confirm cqlprotocol://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c `, Flag: flag.NewFlagSet("Drop params", flag.ExitOnError), CommonFlag: flag.NewFlagSet("Common params", flag.ExitOnError), DebugFlag: flag.NewFlagSet("Debug params", flag.ExitOnError), }
CmdDrop is cql drop command entity.
var CmdExplorer = &Command{ UsageLine: "cql explorer [common params] [-tmp-path path] [-bg-log-level level] listen_address", Short: "start a SQLChain explorer server", Long: ` Explorer serves a SQLChain web explorer. e.g. cql explorer 127.0.0.1:8546 `, Flag: flag.NewFlagSet("Explorer params", flag.ExitOnError), CommonFlag: flag.NewFlagSet("Common params", flag.ExitOnError), DebugFlag: flag.NewFlagSet("Debug params", flag.ExitOnError), }
CmdExplorer is cql explorer command.
var CmdGenerate = &Command{ UsageLine: "cql generate [common params] [-source template_file] [-miner listen_addr] [-private existing_private_key] [dest_path]", Short: "generate a folder contains config file and private key", Long: ` Generate generates private.key and config.yaml for CQL. You can input a passphrase for local encrypt your private key file by set -with-password e.g. cql generate or input a passphrase by cql generate -with-password `, Flag: flag.NewFlagSet("Generate params", flag.ExitOnError), CommonFlag: flag.NewFlagSet("Common params", flag.ExitOnError), DebugFlag: flag.NewFlagSet("Debug params", flag.ExitOnError), }
CmdGenerate is cql generate command entity.
var CmdGrant = &Command{ UsageLine: "cql grant [common params] [-wait-tx-confirm] [-to-user wallet] [-to-dsn dsn] [-perm perm_struct]", Short: "grant a user's permissions on specific sqlchain", Long: ` Grant grants specific permissions for the target user on target dsn. e.g. cql grant -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -to-dsn="cqlprotocol://xxxx" -perm perm_struct Since CQL is built on top of blockchains, you may want to wait for the transaction confirmation before the permission takes effect. e.g. cql grant -wait-tx-confirm -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -to-dsn="cqlprotocol://xxxx" -perm perm_struct `, Flag: flag.NewFlagSet("Grant params", flag.ExitOnError), CommonFlag: flag.NewFlagSet("Common params", flag.ExitOnError), DebugFlag: flag.NewFlagSet("Debug params", flag.ExitOnError), }
CmdGrant is cql grant command entity.
var CmdHelp = &Command{ UsageLine: "cql help [command]", Short: "show help of sub commands", Long: ` Use "cql help <command>" for more information about a command. `, Flag: flag.NewFlagSet("", flag.ExitOnError), CommonFlag: flag.NewFlagSet("", flag.ExitOnError), DebugFlag: flag.NewFlagSet("", flag.ExitOnError), }
CmdHelp is cql help command entity.
var CmdIDMiner = &Command{ UsageLine: "cql idminer [common params] [-difficulty number] [-loop [true]]", Short: "calculate nonce and node id for config.yaml file", Long: ` IDMiner calculates legal node id and it's nonce. Default parameters are difficulty of 24 and no endless loop. e.g. cql idminer -difficulty 24 If you want mining a good id, use: cql idminer -config ~/.cql/config.yaml -loop -difficulty 24 `, Flag: flag.NewFlagSet("IDMiner params", flag.ExitOnError), CommonFlag: flag.NewFlagSet("Common params", flag.ExitOnError), DebugFlag: flag.NewFlagSet("Debug params", flag.ExitOnError), }
CmdIDMiner is cql idminer command entity.
var CmdRPC = &Command{ UsageLine: "cql rpc [common params] [-wait-tx-confirm] [-endpoint rpc_endpoint | -bp] -name rpc_name -req rpc_request", Short: "make a rpc request", Long: ` RPC makes a RPC request to the target endpoint. e.g. cql rpc -name 'MCC.QuerySQLChainProfile' \ -endpoint 000000fd2c8f68d54d55d97d0ad06c6c0d91104e4e51a7247f3629cc2a0127cf \ -req '{"DBID": "c8328272ba9377acdf1ee8e73b17f2b0f7430c798141080d0282195507eb94e7"}' `, Flag: flag.NewFlagSet("RPC params", flag.ExitOnError), CommonFlag: flag.NewFlagSet("Common params", flag.ExitOnError), DebugFlag: flag.NewFlagSet("Debug params", flag.ExitOnError), }
CmdRPC is cql rpc command entity.
var CmdTransfer = &Command{ UsageLine: "cql transfer [common params] [-wait-tx-confirm] [-to-user wallet | -to-dsn dsn] [-amount count] [-token token_type]", Short: "transfer token to target account", Long: ` Transfer transfers your token to the target account or database. The command arguments are target wallet address(or dsn), amount of token, and token type. e.g. cql transfer -to-user=43602c17adcc96acf2f68964830bb6ebfbca6834961c0eca0915fcc5270e0b40 -amount=100 -token=Particle Since CovenantSQL is built on top of the blockchain, you need to wait for the transaction confirmation before the transfer takes effect. e.g. cql transfer -wait-tx-confirm -to-dsn="cqlprotocol://xxxx" -amount=100 -token=Particle `, Flag: flag.NewFlagSet("Transfer params", flag.ExitOnError), CommonFlag: flag.NewFlagSet("Common params", flag.ExitOnError), DebugFlag: flag.NewFlagSet("Debug params", flag.ExitOnError), }
CmdTransfer is cql transfer command entity.
var CmdVersion = &Command{ UsageLine: "cql version", Short: "show build version information", Long: ` Use "cql help <command>" for more information about a command. `, Flag: flag.NewFlagSet("", flag.ExitOnError), CommonFlag: flag.NewFlagSet("", flag.ExitOnError), DebugFlag: flag.NewFlagSet("", flag.ExitOnError), }
CmdVersion is cql version command entity.
var CmdWallet = &Command{ UsageLine: "cql wallet [common params] [-token type] [-dsn dsn]", Short: "get the wallet address and the balance of current account", Long: ` Wallet gets the wallet address and the token balances of the current account. e.g. cql wallet cql wallet -token Particle cql wallet -dsn "cqlprotocol://4119ef997dedc585bfbcfae00ab6b87b8486fab323a8e107ea1fd4fc4f7eba5c" `, Flag: flag.NewFlagSet("Wallet params", flag.ExitOnError), CommonFlag: flag.NewFlagSet("Common params", flag.ExitOnError), DebugFlag: flag.NewFlagSet("Debug params", flag.ExitOnError), }
CmdWallet is cql wallet command entity.
var (
// Version of command, set by main func of version
Version = "unknown"
)
Functions ¶
func PrintVersion ¶
PrintVersion prints program git version.
func SetExitStatus ¶
func SetExitStatus(n int)
SetExitStatus provide thread safe set exit status func.
Types ¶
type Command ¶
type Command struct { // Run runs the command. // The args are the arguments after the command name. Run func(cmd *Command, args []string) // UsageLine is the one-line usage message. // The first word in the line is taken to be the command name. UsageLine string // Short is the short description shown in the 'cql help' output. Short string // Long is the long message shown in the 'cql help <this-command>' output. Long string // DebugFlag is a set of debug flags specific to this command. DebugFlag *flag.FlagSet // CommonFlag is a set of common flags specific to this command. CommonFlag *flag.FlagSet // Flag is a set of flags specific to this command. Flag *flag.FlagSet }
A Command is an implementation of a cql command like cql create or cql transfer.
func (*Command) LongName ¶
LongName returns the command's long name: all the words in the usage line between "cql" and a flag or argument,
func (*Command) Name ¶
Name returns the command's short name: the last word in the usage line before a flag or argument.
type List ¶
type List struct {
Values []string
}
List is a list of strings for flag usage.
func (*List) Get ¶
func (l *List) Get() interface{}
Get is a function in List struct for flag usage.