clix: Allow --debug to be anywhere on the command-line

Thu, 07 Jan 2010 20:59:15 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 07 Jan 2010 20:59:15 +0000
changeset 20
80cc61512f10
parent 19
3a0a156e0a79
child 21
cdeb02d9546d

clix: Allow --debug to be anywhere on the command-line

clix.lua file | annotate | diff | comparison | revisions
--- a/clix.lua	Thu Jan 07 20:58:52 2010 +0000
+++ b/clix.lua	Thu Jan 07 20:59:15 2010 +0000
@@ -26,8 +26,14 @@
 
 local ok, m = pcall(require, "clix."..command);
 if not ok then
-	print("Error running command '"..command.."' (run with --debug to see full error)");
-	if arg[2] == "--debug" then
+	local is_debug;
+	for i=1,#arg do
+		if arg[i] == "--debug" then
+			is_debug = true; break;
+		end
+	end
+	print("Error running command '"..command..(is_debug and "" or "' (run with --debug to see full error)"));
+	if is_debug then
 		print(m);
 	end
 	return 1;

mercurial