50 lines
651 B
PHP
Executable File
50 lines
651 B
PHP
Executable File
<?php
|
|
|
|
namespace Vn\Lib;
|
|
|
|
require_once (__DIR__.'/app.php');
|
|
|
|
/**
|
|
* Implements command line applications.
|
|
**/
|
|
class CliApp extends App
|
|
{
|
|
function run ()
|
|
{
|
|
$this->init ();
|
|
|
|
if ($lang = substr (getenv ('LANG'), 0, 2))
|
|
Locale::set ($lang);
|
|
|
|
try {
|
|
$options = getopt ('m:');
|
|
|
|
if (empty ($options['m']))
|
|
$this->usage ();
|
|
|
|
$method = $this->loadMethod ($options['m']);
|
|
$method->run ();
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
echo $e->getMessage ()."\n";
|
|
exit (2);
|
|
}
|
|
}
|
|
|
|
function json ($json)
|
|
{
|
|
print_r ($json);
|
|
echo "\n";
|
|
}
|
|
|
|
function usage ()
|
|
{
|
|
global $argv;
|
|
echo "{$argv[0]} -m method\n";
|
|
exit (1);
|
|
}
|
|
}
|
|
|
|
?>
|