- When the -t option is used the results of a control file run are put in
  <autodir>/results/<tag>

- Use optparse for parsing the autotest parameters

Note: I haven't tested the continue parameter since I don't know how to
use it.

Signed-off-by: Brandon Philips <brandon at ifup.org>

---
 bin/autotest |   25 +++++++++++++------------
 bin/job.py   |   10 +++++-----
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/bin/autotest b/bin/autotest
index b205f5a..351cfb9 100755
--- a/bin/autotest
+++ b/bin/autotest
@@ -6,6 +6,7 @@ import os, sys, shutil
 import job, kernel, test
 from error import *
 from autotest_utils import *
+from optparse import OptionParser
 
 # Use the name of the binary to find the real installation directory
 # aka $AUTODIR.  Update our path to include the $AUTODIR/bin/tests
@@ -23,23 +24,23 @@ os.environ['AUTODIR'] = autodir
 os.environ['AUTODIRBIN'] = autodirbin
 os.environ['PYTHONPATH'] = autodirbin
 
+parser = OptionParser()
+
+parser.add_option("-c", "--continue", dest="cont", action="store_true", 
+			default=False, help="continue previously started job")
+		  
+parser.add_option("-t", "--tag", dest="tag", type="string", default="default",
+			help="set the job tag")
+
 def usage():
-	os.stderr.write("Usage: autotest [--continue] <control file>\n");
+	parser.print_help()
 	sys.exit(1)
 
-# Usage check.
-if len(sys.argv) < 2:
-	usage()
+options, args = parser.parse_args()
 
-# A multi-phase job is continued using the --continue option.
-cont = 0
-if sys.argv[1] == '--continue':
-	sys.argv.pop(1)
-	cont = 1
-	
 # Check for a control file.
-if len(sys.argv) != 2:
+if len(args) != 1:
 	usage()
 
 # JOB: run the specified job control file.
-job.runjob(sys.argv[1], cont)
+job.runjob(args[0], options.cont, options.tag)
diff --git a/bin/job.py b/bin/job.py
index 6106b8c..cda19f9 100755
--- a/bin/job.py
+++ b/bin/job.py
@@ -43,7 +43,7 @@ class job:
 			the profilers object for this job
 	"""
 
-	def __init__(self, control, jobtag='default'):
+	def __init__(self, control, jobtag):
 		"""
 			control
 				The control file (pathname of)
@@ -221,7 +221,7 @@ from autotest_utils import *
 		fd.close()
 
 
-def runjob(control, cont = 0):
+def runjob(control, cont = False, tag = "default"):
 	"""The main interface to this module
 
 	control	
@@ -240,12 +240,12 @@ def runjob(control, cont = 0):
 
 		# When continuing, the job is complete when there is no
 		# state file, ensure we don't try and continue.
-		if cont == 1 and not os.path.exists(state):
+		if cont and not os.path.exists(state):
 			sys.exit(1)
-		if cont == 0 and os.path.exists(state):
+		if cont == False and os.path.exists(state):
 			os.unlink(state)
 
-		myjob = job(control)
+		myjob = job(control, tag)
 
 		# Load in the users control file, may do any one of:
 		#  1) execute in toto
