Update usage
This commit is contained in:
parent
deb7e2ce03
commit
75105982ae
33
cli.go
33
cli.go
|
@ -48,23 +48,7 @@ func (cli *CLI) listAddresses() {
|
|||
}
|
||||
}
|
||||
|
||||
func (cli *CLI) printUsage() {
|
||||
fmt.Println("Usage:")
|
||||
fmt.Println(" getbalance -address ADDRESS - Get balance of ADDRESS")
|
||||
fmt.Println(" createblockchain -address ADDRESS - Create a blockchain and send genesis block reward to ADDRESS")
|
||||
fmt.Println(" printchain - Print all the blocks of the blockchain")
|
||||
fmt.Println(" send -from FROM -to TO -amount AMOUNT - Send AMOUNT of coins from FROM address to TO")
|
||||
}
|
||||
|
||||
func (cli *CLI) validateArgs() {
|
||||
if len(os.Args) < 2 {
|
||||
cli.printUsage()
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func (cli *CLI) printChain() {
|
||||
// TODO: Fix this
|
||||
bc := NewBlockchain("")
|
||||
defer bc.db.Close()
|
||||
|
||||
|
@ -94,6 +78,23 @@ func (cli *CLI) send(from, to string, amount int) {
|
|||
fmt.Println("Success!")
|
||||
}
|
||||
|
||||
func (cli *CLI) printUsage() {
|
||||
fmt.Println("Usage:")
|
||||
fmt.Println(" createblockchain -address ADDRESS - Create a blockchain and send genesis block reward to ADDRESS")
|
||||
fmt.Println(" createwallet - Generates a new key-pair and saves it into the wallet file")
|
||||
fmt.Println(" getbalance -address ADDRESS - Get balance of ADDRESS")
|
||||
fmt.Println(" listaddresses - Lists all addresses from the wallet file")
|
||||
fmt.Println(" printchain - Print all the blocks of the blockchain")
|
||||
fmt.Println(" send -from FROM -to TO -amount AMOUNT - Send AMOUNT of coins from FROM address to TO")
|
||||
}
|
||||
|
||||
func (cli *CLI) validateArgs() {
|
||||
if len(os.Args) < 2 {
|
||||
cli.printUsage()
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Run parses command line arguments and processes commands
|
||||
func (cli *CLI) Run() {
|
||||
cli.validateArgs()
|
||||
|
|
Loading…
Reference in New Issue