import parseopt, strutils import os var remoteHost*: seq[string] localPort*: int proc printHelp = const msg = """ wsabi - load balance, monitor and failover Openfire websockets usage: wsabi --localPort=PORT --remoteHost=REMOTE,REMOTE... """ echo msg proc parseArgs* = var p = initOptParser() if paramCount() == 0: printHelp() quit 0 while true: p.next() case p.kind of cmdEnd: break of cmdLongOption: if p.key == "localPort": localPort = parseInt(p.val) elif p.key == "remoteHost": remoteHost = p.val.strip().split(",") else: printHelp() quit 0 of cmdArgument, cmdShortOption: printHelp() quit 0