diff --git a/php/src/app/args/AbstractArgsParser.php b/php/src/app/args/AbstractArgsParser.php index fdd76f1..92df216 100644 --- a/php/src/app/args/AbstractArgsParser.php +++ b/php/src/app/args/AbstractArgsParser.php @@ -65,14 +65,14 @@ abstract class AbstractArgsParser { if ($opt === "--") { # fin des arguments facultatifs en entrée $eoo = true; - if ($keepsep) $dest[] = $opt; + if ($keepsep) $dest[] = "--"; break; } $dest[] = $opt; } if (!$eoo && $desti < $destmax) { # pas assez d'arguments en entrée, terminer avec "--" - $dest[] = "--"; + if ($keepsep) $dest[] = "--"; } return 0; } diff --git a/php/src/app/args/Aodef.php b/php/src/app/args/Aodef.php index d7904f7..89d9da2 100644 --- a/php/src/app/args/Aodef.php +++ b/php/src/app/args/Aodef.php @@ -239,7 +239,8 @@ class Aodef { } function addOptions(?array $options): void { - A::merge($this->_options, $this->buildOptions($options)); + // les options pouvant être numériques (e.g "-1"), utiliser A::merge2 + A::merge2($this->_options, $this->buildOptions($options)); $this->updateType(); } diff --git a/php/tbin/test-application.php b/php/tbin/test-application.php index bd2ff67..a196a27 100755 --- a/php/tbin/test-application.php +++ b/php/tbin/test-application.php @@ -12,6 +12,21 @@ Application::run(new class extends Application { "usage" => "-A|-a|-b", "merge" => parent::ARGS, + "sections" => [ + [ + "title" => "Section X", + "show" => false, + ["group", + ["-X:", "--setx", "args" => "int", "name" => "x", + "help" => "spécifier x", + ], + ["--setx10", "name" => "x", "value" => 10], + ["--setx20", "name" => "x", "value" => 20], + ], + ["-x", "--incx", "name" => "x"], + ["-y", "--decx", "name" => "x", "inverse" => true], + ], + ], ["group", ["-A:", "--seta", "args" => "int", "name" => "a", "help" => "spécifier a", @@ -28,27 +43,19 @@ Application::run(new class extends Application { ["-D::", "--override", "help" => "++remplace celui de la section principale", ], - "sections" => [ - [ - "title" => "Section X", - "show" => false, - ["group", - ["-X:", "--setx", "args" => "int", "name" => "x", - "help" => "spécifier x", - ], - ["--setx10", "name" => "x", "value" => 10], - ["--setx20", "name" => "x", "value" => 20], - ], - ["-x", "--incx", "name" => "x"], - ["-y", "--decx", "name" => "x", "inverse" => true], - ], - ], - ["args" => [["value", "value"]], "name" => "args"], + ["-1:first", "--one", "help" => "un argument"], + ["-2:first,second", "--two", "help" => "deux arguments"], + ["-3", "args" => ""], + //["args" => [["value", "value"]], "name" => "args"], + //["args" => ["value", ["value"]], "name" => "args"], + //["args" => ["value", "value"], "name" => "args"], ]; private ?int $a = null; private ?int $x = null; private ?string $override = null; + private ?string $one = null; + private ?array $two = null; function main() { $profile = app::get_profile($productionMode); @@ -63,6 +70,8 @@ Application::run(new class extends Application { "\na=", var_export($this->a, true), "\nx=", var_export($this->x, true), "\noverride=", var_export($this->override, true), + "\none=", var_export($this->one, true), + "\ntwo=", var_export($this->two, true), "\nargs=", var_export($this->args, true), ]); } diff --git a/php/tbin/test_mail.php b/php/tbin/test-mail.php similarity index 100% rename from php/tbin/test_mail.php rename to php/tbin/test-mail.php diff --git a/php/tbin/test_mysql.php b/php/tbin/test-mysql.php similarity index 100% rename from php/tbin/test_mysql.php rename to php/tbin/test-mysql.php diff --git a/php/tbin/test_pgsql.php b/php/tbin/test-pgsql.php similarity index 100% rename from php/tbin/test_pgsql.php rename to php/tbin/test-pgsql.php diff --git a/php/tbin/test_sqlite.php b/php/tbin/test-sqlite.php similarity index 100% rename from php/tbin/test_sqlite.php rename to php/tbin/test-sqlite.php