You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.9 KiB
PHP
37 lines
1.9 KiB
PHP
<?php
|
|
|
|
require_once '../src/CommandLine/Exception/IException.php';
|
|
require_once '../src/CommandLine/Exception/IncorrectParse.php';
|
|
require_once '../src/CommandLine/Argument/ParseResult.php';
|
|
require_once '../src/CommandLine/CommandLine.php';
|
|
require_once '../src/CommandLine/Argument/IArgument.php';
|
|
require_once '../src/CommandLine/Argument/IArgumentValueDescription.php';
|
|
require_once '../src/CommandLine/Argument/Option/IArgumentOption.php';
|
|
require_once '../src/CommandLine/Argument/ArgumentAbstract.php';
|
|
require_once '../src/CommandLine/Argument/Option/OptionAbstract.php';
|
|
require_once '../src/CommandLine/Argument/Option/Flag.php';
|
|
require_once '../src/CommandLine/Argument/Option/Value.php';
|
|
require_once '../src/CommandLine/Argument/Value/IArgumentValue.php';
|
|
require_once '../src/CommandLine/Argument/Value/ValueAbstract.php';
|
|
require_once '../src/CommandLine/Argument/Value/Value.php';
|
|
require_once '../src/CommandLine/Argument/Parser/IValueParser.php';
|
|
require_once '../src/CommandLine/Argument/Parser/IntegerParser.php';
|
|
require_once '../src/CommandLine/Argument/Parser/StringParser.php';
|
|
|
|
use CommandLine\Argument\Option\Flag;
|
|
use CommandLine\Argument\Option\Value;
|
|
use CommandLine\Argument\Parser\IntegerParser;
|
|
use CommandLine\Argument\Parser\StringParser;
|
|
use CommandLine\CommandLine;
|
|
|
|
$cmdline = new CommandLine('Test', 'Programme de test', 'php test.php');
|
|
$cmdline->addDefaultArguments();
|
|
$cmdline->addOption(new Flag('array_form', false, 'Sous la forme d\'un tableau ?'));
|
|
$cmdline->addOption((new Value('days', 'Nombre jour', new IntegerParser(0, 365)))->setDefault(3));
|
|
$cmdline->addOption((new Value('years', 'Nombre d\'années', new IntegerParser(0)))->setDefault(5));
|
|
$cmdline->addValue(new \CommandLine\Argument\Value\Value('path', 'Chemin sauvegarde images', new StringParser(), true));
|
|
|
|
$args = $cmdline->parseExplicit(array());
|
|
$cmdline->treatDefaultArguments($args, false);
|
|
|
|
var_dump($args); |