<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>getoptx.sh</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,7 @@
-&quot;The contents of this file and software package (the &quot;Application&quot;) are subject
-to the Mozilla Public License Version 1.1 (the &quot;License&quot;); you may not use
-this file or the Application except in compliance with the License. You may
-obtain a copy of the License at
+&quot;The contents of this file and software package (the &quot;Application&quot;) are
+subject to the Mozilla Public License Version 1.1 (the &quot;License&quot;); you may not
+use this file or the Application except in compliance with the License. You
+may obtain a copy of the License at
 http://www.mozilla.org/MPL/
 
 Software distributed under the License is distributed on an &quot;AS IS&quot;
@@ -11,5 +11,11 @@ under the License.
 
 The Original Code is Snaptest 0.0.1 [no formal release yet].
 
-The Initial Developer of the Original Code is Jakob Heuser &lt;jakob@felocity.org&gt;.
-Copyright (C) 2007. All Rights Reserved.
\ No newline at end of file
+The Initial Developer of the Original Code is Jakob Heuser
+&lt;jakob@felocity.org&gt;.
+Copyright (C) 2007. All Rights Reserved.
+
+---
+
+getoptx.sh is licensed under the Public Domain and may be distributed on its
+own, independent of this software package.
\ No newline at end of file</diff>
      <filename>LICENSE</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,31 @@
 &lt;?php
 
+function SNAP_usage() {
+    echo &quot;\n&quot;;
+    echo &quot;Usage: snaptest.sh [--out=outmode] [--php=phppath] [--help] &lt;path&gt;\n&quot;;
+    echo &quot;Usage: php snaptest.php [--out=outmode] [--php=phppath] [--help] &lt;path&gt;\n&quot;;
+    echo &quot;\n&quot;;
+    echo &quot;&lt;path&gt; :: The path to the test you want to run. Should be a file\n&quot;;
+    echo &quot;ending in .test.php or a directory.\n&quot;;
+    echo &quot;\n&quot;;
+    echo &quot;--out=outmode :: sets the output handler to 'outmode'. The\n&quot;;
+    echo &quot;output mode must be located in &lt;snaptest&gt;/outmode.php.\n&quot;;
+    echo &quot;\n&quot;;
+    echo &quot;--php=phppath :: set the php path for recursion. If not specified,\n&quot;;
+    echo &quot;the call 'php' will be used, using whatever is in the current env\n&quot;;
+    echo &quot;variable.\n&quot;;
+    echo &quot;\n&quot;;
+    echo &quot;--match=regex :: Specifies a PCRE regular expression to match. Files\n&quot;;
+    echo &quot;that match this regular expression will be included by the test\n&quot;;
+    echo &quot;harness.\n&quot;;
+    exit;
+}
+
+// requires PHP 5.2+
+if (version_compare(phpversion(), '5.2.0') &lt; 0) {
+    SNAP_usage();
+}
+
 require_once 'snap.php';
 require_once 'functions.php';
 
@@ -18,40 +44,13 @@ $out_mode = (isset($options['out']) &amp;&amp; $options['out']) ? $options['out'] : 'tex
 $php = (isset($options['php']) &amp;&amp; $options['php']) ? $options['php'] : 'php';
 $ofile = (isset($options['ofile']) &amp;&amp; $options['ofile']) ? $options['ofile'] : tempnam('/tmp', 'SNAP');
 $xtn = (isset($options['match']) &amp;&amp; $options['match']) ? $options['match'] : '^.*\.stest\.php';
-$help = (isset($options['help']) &amp;&amp; $options['help']) ? true : false;
+$help = (isset($options['help'])) ? true : false;
 
 $path = (isset($options[0]) &amp;&amp; $options[0]) ? $options[0] : '';
 
 // help output if no path is specified
 if ($path == '' || $help) {
-    echo &quot;\n&quot;;
-    echo &quot;Usage: snaptest.sh &lt;path&gt;\n&quot;;
-    echo &quot;Usage: php snaptest.php [--out=outmode] [--php=phppath]\n&quot;;
-    echo &quot;           [--ofile=filepath] [--help] &lt;path&gt;\n&quot;;
-    echo &quot;\n&quot;;
-    echo &quot;&lt;path&gt; :: The path to the test you want to run. Should be a file\n&quot;;
-    echo &quot;ending in .test.php or a directory.\n&quot;;
-    echo &quot;\n&quot;;
-    echo &quot;--out=outmode :: sets the output handler to 'outmode'. The\n&quot;;
-    echo &quot;output mode must be located in &lt;snaptest&gt;/outmode.php.\n&quot;;
-    echo &quot;This is specific to snaptest.php only\n&quot;;
-    echo &quot;\n&quot;;
-    echo &quot;--php=phppath :: set the php path for recursion. If not specified,\n&quot;;
-    echo &quot;the call 'php' will be used, using whatever is in the current env\n&quot;;
-    echo &quot;variable.\n&quot;;
-    echo &quot;This is specific to snaptest.php only\n&quot;;
-    echo &quot;\n&quot;;
-    echo &quot;--ofile=filepath :: Declare a file you want to write to. This is\n&quot;;
-    echo &quot;especially useful if you plan to fork and want all reports to go\n&quot;;
-    echo &quot;to a single location. If ofile is not specified, a file in /tmp\n&quot;;
-    echo &quot;from tempnam() will be used.\n&quot;;
-    echo &quot;This is specific to snaptest.php only\n&quot;;
-    echo &quot;\n&quot;;
-    echo &quot;--match=regex :: Specifies a regular expression to match. Files\n&quot;;
-    echo &quot;that match this regular expression will be included by the test\n&quot;;
-    echo &quot;harness.\n&quot;;
-    echo &quot;This is specific to snaptest.php only\n&quot;;
-    exit;
+    SNAP_usage();
 }
 
 </diff>
      <filename>snaptest.php</filename>
    </modified>
    <modified>
      <diff>@@ -1,17 +1,58 @@
 #!/bin/bash
 
-#$&gt; ./snaptest.sh &lt;path&gt;
-#        runs snaptest/bootstrap.php --mode=directory --path=&lt;path&gt;
-#
+# load options
+. getoptx.sh
 
-# Debian / STD Linux
-# phppath=/usr/local/bin/php
+# Auto Locate PHP
+PHP=`which php`
+if [[ ! -x &quot;$PHP&quot; ]] ; then
+    PHP=&quot;&quot;
+    if [ -z $PHP ] ; then
+        if [ -x &quot;/usr/local/bin/php&quot; ] ; then
+            PHP=&quot;/usr/local/bin/php&quot;
+        fi
+        if [ -x &quot;/usr/bin/php&quot; ] ; then
+            PHP=&quot;/usr/bin/php&quot;
+        fi
+        if [ -x &quot;/opt/local/bin/php&quot; ] ; then
+            PHP=&quot;/opt/local/bin/php&quot;
+        fi
+    fi
+fi
 
-# OSX / Darwin
-phppath=/opt/local/bin/php
+# choke and die if we couldn't auto-find PHP
+if [ -z $PHP ] ; then
+    echo &quot;PHP was not found in any common location. You will need to&quot;
+    echo &quot;supply the --php=&lt;path&gt; switch.&quot;
+    exit 0
+fi
 
-# END CONFIG
-filepath=`dirname &quot;$0&quot;`
-cd $filepath;
+# parse the options
+CMD=&quot;&quot;
+while getoptex &quot;out. php. match. help;&quot; &quot;$@&quot;
+do
+    if [ &quot;$OPTOPT&quot; = &quot;php&quot; ] ; then
+        if [ -n PHP ] ; then
+            echo &quot;OHSHITNOPHPLAWL&quot;
+        fi
+        PHP=$OPTARG
+    fi
+    if [ &quot;$OPTOPT&quot; = &quot;help&quot; ] ; then
+        CMD=&quot;$CMD --help&quot;
+    else
+        CMD=&quot;$CMD --$OPTOPT=$OPTARG&quot;
+    fi
+done
+shift $[OPTIND-1]
+for arg in &quot;$@&quot;
+do
+    CMD=&quot;$CMD $arg&quot;
+done
 
-$phppath $filepath/snaptest.php --out=text --php=$phppath $1
\ No newline at end of file
+# change to shell script real location
+FPATH=`dirname &quot;$0&quot;`
+cd $FPATH;
+
+# run php on the snaptest.php file with the commands
+CMD=&quot;$PHP snaptest.php $CMD&quot;
+$CMD</diff>
      <filename>snaptest.sh</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7db4664b4f39dddc6c864f23692f4e0672ac8ac1</id>
    </parent>
  </parents>
  <author>
    <name>rjheuser</name>
    <email>rjheuser@85759191-e132-0410-920c-21c98535aa7c</email>
  </author>
  <url>http://github.com/Jakobo/snaptest/commit/21f361e04e32a7b35f6ed0001437aff78afe00a3</url>
  <id>21f361e04e32a7b35f6ed0001437aff78afe00a3</id>
  <committed-date>2008-01-16T15:56:26-08:00</committed-date>
  <authored-date>2008-01-16T15:56:26-08:00</authored-date>
  <message>command line option improvement

the shell script now attempts to auto locate PHP, followed by running a PHP
version check before starting. getoptx has been added for simplicity in
handling long options, until it has been changed over to getopt native


git-svn-id: https://snaptest.googlecode.com/svn/trunk@49 85759191-e132-0410-920c-21c98535aa7c</message>
  <tree>b01ab38e8e0a635c7b8c1015153c312e8653983f</tree>
  <committer>
    <name>rjheuser</name>
    <email>rjheuser@85759191-e132-0410-920c-21c98535aa7c</email>
  </committer>
</commit>
