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.
phpcommandline/Tests/test.php

23 lines
905 B
PHP

<?php
require_once '../vendor/autoload.php';
use CommandLine\Argument\Option\Flag;
use CommandLine\Argument\Option\Value;
use CommandLine\Argument\Parser\IntegerParser;
use CommandLine\Argument\Parser\PathParser;
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 ?'."\n".'Ou pas'));
$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 PathParser(), true)));
$args = $cmdline->parse();
$cmdline->treatDefaultArguments($args, false);
echo "\n";
var_dump($args);
var_dump((string)$args->path);