From: William Orr Date: Wed, 24 Apr 2013 05:11:12 +0000 (-0400) Subject: Wrote irkerd usage X-Git-Tag: 1.19~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bf23f0a9d75276182a377e0df7d42ce9291857c3;p=irker.git Wrote irkerd usage - invalid options should print usage --- diff --git a/irkerd b/irkerd index 731b3d1..1b25d92 100755 --- a/irkerd +++ b/irkerd @@ -552,12 +552,31 @@ class IrkerUDPHandler(SocketServer.BaseRequestHandler): #socket = self.request[1] irker.handle(data) +def usage(): + sys.stdout.write(""" +Usage: + irkerd [-d debuglevel] [-l logfile] [-n nick] [-p password] [-V] [-h] + +Options + -d set debug level + -l set logfile + -n set nick-style + -p set nickserv password + -V return irkerd version + -h print this help dialog +""") + if __name__ == '__main__': debuglvl = 0 namestyle = "irker%03d" password = None logfile = None - (options, arguments) = getopt.getopt(sys.argv[1:], "d:l:n:p:V") + try: + (options, arguments) = getopt.getopt(sys.argv[1:], "d:l:n:p:Vh") + except getopt.GetoptError as e: + sys.stderr.write("%s" % e) + usage() + sys.exit(1) for (opt, val) in options: if opt == '-d': # Enable debug/progress messages debuglvl = int(val) @@ -572,6 +591,9 @@ if __name__ == '__main__': elif opt == '-V': # Emit version and exit sys.stdout.write("irkerd version %s\n" % version) sys.exit(0) + elif opt == '-h': + usage() + sys.exit(0) fallback = re.search("%.*d", namestyle) irker = Irker(debuglevel=debuglvl) irker.debug(1, "irkerd version %s" % version) diff --git a/irkerd.xml b/irkerd.xml index 6102245..2af5a33 100644 --- a/irkerd.xml +++ b/irkerd.xml @@ -23,6 +23,7 @@ -n nick -p password -V + -h @@ -100,6 +101,11 @@ authenticate the nick on receipt of a welcom message. Write the program version to stdout and terminate. + +-h +Print usage instructions and +terminate. +