Exemple #1
0
require '../src/Fortissimo.php';
if ($argc <= 1) {
    printf('%s expects at least one parameter. Try --help.' . PHP_EOL, $argv[0]);
    exit(1);
} elseif ($argv[1] == '--help') {
    printf('This is a command-line Fortissimo command runner.' . PHP_EOL);
    printf('Syntax: %s COMMAND [ARGUMENTS]' . PHP_EOL, $argv[0]);
    exit(0);
}
// Try to find the commands file:
$cwd = getcwd();
$bases = array($cwd, $cwd . '/src', $cwd . '/../src');
$basedir = NULL;
foreach ($bases as $base) {
    if (is_file($base . '/config/commands.php')) {
        //$practicalBase = $base;
        $basedir = $base;
        // . '/config/commands.php';
        break;
    }
}
if (empty($basedir)) {
    print 'No configuration file found. Quitting.' . PHP_EOL;
    exit(1);
}
chdir($basedir);
/*
 * Build a new Fortissimo server and execute the command. 
 */
$ff = new Fortissimo('config/commands.php');
$ff->handleRequest($argv[1]);
 public function __construct($file = NULL)
 {
     if (isset($file)) {
         \Fortissimo\Registry::initialize();
     }
     parent::__construct($file);
 }
        return 0;
    }
    return 1;
}
function cisort($a, $b)
{
    $la = strtolower($a);
    $lb = strtolower($b);
    if ($la == $lb) {
        return 0;
    }
    return $la > $lb ? 1 : -1;
}
# now we create a basic object for them to use
global $ft;
$ft = new Fortissimo();
$ft->setup_session();
# now give them a global remote object
global $remote;
$remote = $ft->session->user;
# and now define some functions we're going to need later, perhaps
$ft->register_function("left_box_start", "left_box_start");
$ft->register_function("left_box_end", "left_box_end");
$ft->register_function("left_box_link", "left_box_link");
$ft->register_modifier("commify", "commify");
$ft->register_modifier("isk", "isk");
$ft->register_modifier("standings", "standings");
$ft->register_modifier("security", "security");
$ft->register_modifier("security_color", "security_color");
$ft->register_modifier("minsecs", "minsecs");
$ft->register_modifier("how_long_ago", "how_long_ago");