Show help automatically when no arguments presented, show error when no server address is given.

Sat, 08 May 2010 19:29:23 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 08 May 2010 19:29:23 +0100
changeset 5
05ee9f5fcefc
parent 4
0677d0506878
child 6
69af027ed4b8

Show help automatically when no arguments presented, show error when no server address is given.

xmpp-fingerprint.lua file | annotate | diff | comparison | revisions
--- a/xmpp-fingerprint.lua	Sat May 08 19:28:35 2010 +0100
+++ b/xmpp-fingerprint.lua	Sat May 08 19:29:23 2010 +0100
@@ -70,7 +70,17 @@
 		return process_args(arg);
 	end
 end
-process_args(arg);
+if #arg > 0 then
+	process_args(arg);
+else
+	flags.help();
+	os.exit(1);
+end
+
+if not server then
+	io.stderr:write("ERROR: No server address specified.\n");
+	os.exit(1);
+end
 
 local received_cache = {};
 local function _test(server, port, question, answer)

mercurial