all repos — wsabi @ 7101712b5ca29826d943b141badf7bd59742e76d

websocket proxy that sends stats to statsd

src/wsabipkg/args.nim (view raw)

 1import parseopt, strutils
 2import os
 3
 4var
 5  remoteHost*: seq[string]
 6  localPort*: int
 7
 8
 9proc printHelp =
10  const msg = """
11wsabi - load balance, monitor and failover Openfire websockets
12
13usage:
14  wsabi --localPort=PORT --remoteHost=REMOTE,REMOTE...
15  """
16  echo msg
17
18proc parseArgs* =
19  var p = initOptParser()
20  if paramCount() == 0:
21    printHelp()
22    quit 0
23  while true:
24    p.next()
25    case p.kind
26    of cmdEnd: break
27    of cmdLongOption:
28      if p.key == "localPort":
29        localPort = parseInt(p.val)
30      elif p.key == "remoteHost":
31        remoteHost = p.val.strip().split(",")
32      else:
33        printHelp()
34        quit 0
35    of cmdArgument, cmdShortOption:
36      printHelp()
37      quit 0
38