Skip to content

Commit

Permalink
Merge pull request #110 from ChihChengLiang/add-version-cli
Browse files Browse the repository at this point in the history
Fix #107, Add version cli
  • Loading branch information
ChihChengLiang authored Nov 15, 2018
2 parents 38c8c82 + 1b99873 commit 9bef8ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
main
sharding-p2p-poc
.DS_Store
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: go

sudo: false

go:
- "1.10.x"

Expand Down
3 changes: 3 additions & 0 deletions cli-example/iterate_all_rpc_call.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ remove_peer() {

go build

# check version
$EXE_NAME version

for i in `seq 0 1`;
do
spinup_node $i
Expand Down
13 changes: 12 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ type (
)

const (
VersionMajor = 0
VersionMinor = 0
VersionPatch = 0
numShards ShardIDType = 100
defaultListenPort = 10000
defaultRPCPort = 13000
Expand Down Expand Up @@ -75,8 +78,16 @@ func main() {
notifierAddr := fmt.Sprintf("%v:%v", *rpcIP, *notifierPort)
logging.SetLogLevel("sharding-p2p", *logLevel)

cliArgs := flag.Args()

if len(cliArgs) > 0 && cliArgs[0] == "version" {
version := fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
fmt.Println(version)
return
}

if *isClient {
runClient(rpcAddr, flag.Args())
runClient(rpcAddr, cliArgs)
} else {
runServer(*listenIP, *listenPort, *seed, *doBootstrapping, *bootnodesStr, rpcAddr, notifierAddr)
}
Expand Down

0 comments on commit 9bef8ee

Please sign in to comment.