Пример #1
0
<?php

// ./Examples/Tsv.php
include __DIR__ . '/../Phargs/Init.php';
$factory = new \Phargs\Factory();
$screen = $factory->screen();
// Get a TSV formatter
$table = $factory->tsv();
$table->setFields(array('id', 'name'));
$table->addRows(array(array(1, 'Tom'), array(2, 'Dick'), array(3, 'Harry')));
$screen->out($table);
Пример #2
0
<?php

// ./Examples/PrompterBasic.php
include __DIR__ . '/../Phargs/Init.php';
$factory = new \Phargs\Factory();
$screen = $factory->screen();
// Get a prompter
$prompter = $factory->prompter();
// Prompt for some input
$name = $prompter->prompt('What is your name? ');
// Do something with the response
$screen->outln("Hello, {$name}!");
Пример #3
0
<?php

// ./Examples/ParamAliases.php
include __DIR__ . '/../Phargs/Init.php';
$factory = new \Phargs\Factory();
$args = $factory->args();
// Expect the --count param
$args->expectParam('--count');
// Alias --count to -c so that either can be used
$args->addParamAlias('--count', '-c');
if ($args->paramIsSet('--count')) {
    echo "--count param is set\n";
    echo "--count value is: ";
    echo $args->getParamValue('-c') . PHP_EOL;
} else {
    echo "--count param is not set\n";
}
Пример #4
0
<?php

// ./Examples/ScreenBasic.php
include __DIR__ . '/../Phargs/Init.php';
$factory = new \Phargs\Factory();
// Get a screen interface
$screen = $factory->screen();
$screen->out("Hello, ");
$screen->outln("World!");
$screen->err("Error ");
$screen->errln("message");
$screen->printf("When in %s" . PHP_EOL, "Rome");
$testVar = array(1, 2, 3);
$screen->varExport($testVar);
$screen->log('A log message');