Allow config file to be specified with flag on the command-line

Sat, 11 Jul 2009 03:36:57 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 11 Jul 2009 03:36:57 +0100
changeset 9
13eb9435e1c0
parent 8
6dc28a66f4d9
child 10
58f3707e44d7

Allow config file to be specified with flag on the command-line

util.lua file | annotate | diff | comparison | revisions
--- a/util.lua	Sat Jul 11 02:56:08 2009 +0100
+++ b/util.lua	Sat Jul 11 03:36:57 2009 +0100
@@ -9,8 +9,16 @@
 end
 
 -- Config --
-
-dofile(arg[1] or ".blogrc")
+local conffile = ".blogrc";
+for i=1,#arg do
+	if arg[i] == "-c" or arg[i] == "--config" then
+		table.remove(arg, i);
+		conffile = arg[i] or conffile;
+		table.remove(arg, i);
+		break;
+	end
+end
+dofile(conffile)
 
 posts_dir = posts_dir or "_posts/"
 layouts_dir = layouts_dir or "_layouts/"

mercurial