src/wsabi/args.nim (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
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 |