From 75105982ae6d983755e700a2ea148b2fb7132b4a Mon Sep 17 00:00:00 2001 From: Ivan Kuznetsov Date: Fri, 8 Sep 2017 09:53:26 +0700 Subject: [PATCH] Update usage --- cli.go | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/cli.go b/cli.go index 5b6e24f..44de517 100644 --- a/cli.go +++ b/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()