blob: 282b774be5c79eb57776e964a8b940714389b350 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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);
|