Implement basic CLI

This commit is contained in:
Ivan Kuznetsov 2017-08-28 16:48:53 +07:00
parent d99bbc1b63
commit 52477175c1
1 changed files with 23 additions and 13 deletions

14
main.go
View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"os"
"strconv"
)
@ -9,9 +10,17 @@ func main() {
bc := NewBlockchain()
defer bc.db.Close()
// bc.AddBlock("Send 1 BTC to Ivan")
// bc.AddBlock("Send 2 more BTC to Ivan")
if len(os.Args) < 2 {
fmt.Println("Wrong!")
os.Exit(1)
}
if os.Args[1] == "addBlock" {
bc.AddBlock(os.Args[2])
fmt.Println("Success!")
}
if os.Args[1] == "printChain" {
bci := bc.Iterator()
for {
@ -29,3 +38,4 @@ func main() {
}
}
}
}