diff options
| author | Christian Schneider | 2007-11-09 18:40:56 +0000 | 
|---|---|---|
| committer | Christian Schneider | 2007-11-09 18:40:56 +0000 | 
| commit | 6e2681528377b7bda3199b683f0aaa90de010fec (patch) | |
| tree | 6c9e370c863b6eec31a5f46c6bbfda6df80165c2 /convertsyntax.php | |
| parent | 49eff48cf8ce1e4d734287f4f5305746b02ea26f (diff) | |
| download | itools-6e2681528377b7bda3199b683f0aaa90de010fec.tar.gz itools-6e2681528377b7bda3199b683f0aaa90de010fec.tar.bz2 itools-6e2681528377b7bda3199b683f0aaa90de010fec.zip | |
Added it_autoprepend.php, it_syntaxconverter.class and convertsyntax.php
Diffstat (limited to 'convertsyntax.php')
| -rwxr-xr-x | convertsyntax.php | 43 | 
1 files changed, 43 insertions, 0 deletions
| diff --git a/convertsyntax.php b/convertsyntax.php new file mode 100755 index 0000000..282b774 --- /dev/null +++ b/convertsyntax.php @@ -0,0 +1,43 @@ +#!/usr/bin/env php +<?php + +php_sapi_name() == "cli" or exit("Can only be used from CLI\n"); +ini_set('include_path', dirname(__FILE__) . "/..:" . ini_get('include_path')); +require "itools/itools.lib"; + +$opts = it::getopt(" +	Usage: $argv[0] [OPTIONS] +	  -o, --old	Convert to old syntax (default) +	  -n, --new	Convert to new syntax +	  -t, --test	Test if is old syntax +	  -v, --verbose	Verbose output (otherwise -t only sets result code) +"); + +$mode = $opts['test'] ? 'test' : ($opts['new'] ? 'new' : 'old'); +$files = $opts['args'] ? $opts['args'] : array('php://stdin'); +$result = 0; + +foreach ($files as $file) +{ +	$converter = new it_syntaxconverter(file_get_contents($file), $mode); + +	if ($mode == 'test') +	{ +		if ($converter->changes) +		{ +			if ($opts['verbose']) +				echo "$file contains $converter->changes new syntax elements\n"; + +			$result++; +		} +	} +	else +	{ +		echo $converter->output; + +		if ($opts['verbose'] && $converter->changes) +			fputs(fopen("php://stderr", "w"), "$converter->changes changes made to $file\n"); +	} +} + +exit($result); |