master
Julien Rosset 6 years ago
parent 0742795afa
commit 2f2896a3c8

@ -0,0 +1,37 @@
<?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);
Loading…
Cancel
Save