aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Orr <will@worrbase.com>2013-04-24 01:11:12 -0400
committerWilliam Orr <will@worrbase.com>2013-04-24 01:11:12 -0400
commitbf23f0a9d75276182a377e0df7d42ce9291857c3 (patch)
treee38baf8316373a29ec7c5a1e3e9db5858c132ce2
parentirkerd -V shouldn't take an argument (diff)
downloadirker-bf23f0a9d75276182a377e0df7d42ce9291857c3.tar.xz
Wrote irkerd usage
- invalid options should print usage
-rwxr-xr-xirkerd24
-rw-r--r--irkerd.xml6
2 files changed, 29 insertions, 1 deletions
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 @@
<arg>-n <replaceable>nick</replaceable></arg>
<arg>-p <replaceable>password</replaceable></arg>
<arg>-V</arg>
+ <arg>-h</arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -100,6 +101,11 @@ authenticate the nick on receipt of a welcom message.</para></listitem>
<listitem><para>Write the program version to stdout and
terminate.</para></listitem>
</varlistentry>
+<varlistentry>
+<term>-h</term>
+<listitem><para>Print usage instructions and
+terminate.</para></listitem>
+</varlistentry>
</variablelist>
</refsect1>