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 ( import (
"fmt" "fmt"
"os"
"strconv" "strconv"
) )
@ -9,9 +10,17 @@ func main() {
bc := NewBlockchain() bc := NewBlockchain()
defer bc.db.Close() defer bc.db.Close()
// bc.AddBlock("Send 1 BTC to Ivan") if len(os.Args) < 2 {
// bc.AddBlock("Send 2 more BTC to Ivan") 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() bci := bc.Iterator()
for { for {
@ -28,4 +37,5 @@ func main() {
break break
} }
} }
}
} }