|
|
@@ -0,0 +1,48 @@ |
|
|
|
#!/usr/bin/php5 |
|
|
|
<? |
|
|
|
$aliases = array( |
|
|
|
"-o" => "--save", |
|
|
|
"--output" => "--save" |
|
|
|
); |
|
|
|
|
|
|
|
$ctx = pipi_create_context(); |
|
|
|
$list = pipi_get_command_list(); |
|
|
|
|
|
|
|
for ($argi = 1; $argi < $argc; $argi++) { |
|
|
|
|
|
|
|
$arg = $argv[$argi]; |
|
|
|
if (isset($aliases[$arg])) |
|
|
|
$arg = $aliases[$arg]; |
|
|
|
|
|
|
|
if (substr($arg, 0, 2) == "--") { |
|
|
|
$cmd_name = substr($arg, 2); |
|
|
|
|
|
|
|
if (!isset($list[$cmd_name])) { |
|
|
|
die("unknown command $cmd_name\n"); |
|
|
|
} |
|
|
|
|
|
|
|
$cmd_argc = $list[$cmd_name]; |
|
|
|
if ($argi + $cmd_argc > $argc) { |
|
|
|
die("too few arguments for $arg_name\n"); |
|
|
|
} |
|
|
|
|
|
|
|
switch ($cmd_argc) { |
|
|
|
case 0: |
|
|
|
$res = pipi_command($ctx, $cmd_name); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
$res = pipi_command($ctx, $cmd_name, $argv[$argi + 1]); |
|
|
|
break; |
|
|
|
default: |
|
|
|
die(); |
|
|
|
} |
|
|
|
if ($res != 0) { |
|
|
|
die("command $cmd_name failed\n"); |
|
|
|
} |
|
|
|
$argi += $cmd_argc; |
|
|
|
} |
|
|
|
else { |
|
|
|
if (pipi_command($ctx, "load", $arg) != 0) |
|
|
|
die("could not load $arg\n"); |
|
|
|
} |
|
|
|
} |