コード例 #1
0
ファイル: CliRunner.php プロジェクト: danack/configurator
 public function makeGenerateEnvCommand()
 {
     $configurateCommand = new Command(self::GENENV, ['Configurator\\Configurator', 'writeEnvironmentFile']);
     $configurateCommand->setDescription("Generate a list of env settings into a PHP file");
     $configurateCommand->addArgument('input', InputArgument::REQUIRED, 'The input filename');
     $configurateCommand->addArgument('output', InputArgument::REQUIRED, 'The output filename');
     $configurateCommand->addArgument('environment', InputArgument::REQUIRED, 'What environment to generated the config for.');
     $configurateCommand->addOption('phpsettings', 'p', InputArgument::OPTIONAL, 'A comma separated list of PHP setting files.');
     $configurateCommand->addOption('jssettings', 'j', InputArgument::OPTIONAL, 'A comma separated list of JSON setting files.');
     $configurateCommand->addOption('namespace', 'ns', InputArgument::OPTIONAL, 'An optional namespace for the env function.');
     return $configurateCommand;
 }
コード例 #2
0
ファイル: example.php プロジェクト: Danack/Console
}
//Auryn needs scalars prefixed with a colon and we only
//have scalars here.
function lowrey($params)
{
    $newParams = [];
    foreach ($params as $key => $value) {
        $newParams[':' . $key] = $value;
    }
    return $newParams;
}
$console = new Application();
$console->add(new AboutCommand());
$uploadCommand = new Command('upload', 'uploadFile');
$uploadCommand->addArgument('filename', InputArgument::REQUIRED, 'The name of the file to upload');
$uploadCommand->addOption('dir', null, InputArgument::OPTIONAL, 'Which directory to upload from', './');
$console->add($uploadCommand);
$helloWorldCallable = function ($name) {
    echo "Hello world, and particularly {$name}" . PHP_EOL;
};
$callableCommand = new Command('greet', $helloWorldCallable);
$callableCommand->addArgument('name', InputArgument::REQUIRED, 'The name of the person to say hello to.');
$callableCommand->setDescription("Says hello to the world and one named person");
$console->add($callableCommand);
try {
    $parsedCommand = $console->parseCommandLine();
} catch (\Exception $e) {
    $output = new BufferedOutput();
    $console->renderException($e, $output);
    echo $output->fetch();
    exit(-1);