Skip to content

Commit

Permalink
Merge pull request #32 from bardsoftware/tkt-32-fix-help
Browse files Browse the repository at this point in the history
Fix server help
  • Loading branch information
iisuslik43 committed Jun 25, 2018
2 parents a418656 + 43cb85d commit 827648e
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import io.grpc.Server
import io.grpc.ServerBuilder
import com.xenomachina.argparser.ArgParser
import com.xenomachina.argparser.default
import com.xenomachina.argparser.mainBody
import org.slf4j.LoggerFactory

/**
Expand Down Expand Up @@ -49,9 +50,11 @@ class CosmasServer(port: Int, val service: CosmasGrpc.CosmasImplBase) {
}
}

fun main(args: Array<String>) {

fun main(args: Array<String>) = mainBody {
val LOG = LoggerFactory.getLogger("server main")
val arg = CosmasServerArgs(ArgParser(args))
val parser = ArgParser(args)
val arg = CosmasServerArgs(parser)
LOG.info("Try to bind in port ${arg.port}")
val server =
if (arg.bucket != "") {
Expand All @@ -65,6 +68,10 @@ fun main(args: Array<String>) {
}

class CosmasServerArgs(parser: ArgParser) {
val port: Int by parser.storing("--port", help = "choose port that server will listen to") { toInt() }.default { 50051 }
val bucket: String by parser.storing("--bucket", help = "choose Google Cloud bucket for files storing")
}
val port: Int by parser.storing("--port",
help = "choose port that server will listen to, 50051 by default") { toInt() }.
default { 50051 }
val bucket: String by parser.storing("--bucket",
help = "choose Google Cloud bucket for files storing, \"papeeria-interns-cosmas\" by default").
default { "papeeria-interns-cosmas" }
}

0 comments on commit 827648e

Please sign in to comment.