modifs.mineures sans commentaires
This commit is contained in:
parent
e24c298cd8
commit
7979dc5e69
@ -65,14 +65,14 @@ abstract class AbstractArgsParser {
|
|||||||
if ($opt === "--") {
|
if ($opt === "--") {
|
||||||
# fin des arguments facultatifs en entrée
|
# fin des arguments facultatifs en entrée
|
||||||
$eoo = true;
|
$eoo = true;
|
||||||
if ($keepsep) $dest[] = $opt;
|
if ($keepsep) $dest[] = "--";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$dest[] = $opt;
|
$dest[] = $opt;
|
||||||
}
|
}
|
||||||
if (!$eoo && $desti < $destmax) {
|
if (!$eoo && $desti < $destmax) {
|
||||||
# pas assez d'arguments en entrée, terminer avec "--"
|
# pas assez d'arguments en entrée, terminer avec "--"
|
||||||
$dest[] = "--";
|
if ($keepsep) $dest[] = "--";
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,8 @@ class Aodef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addOptions(?array $options): void {
|
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();
|
$this->updateType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,21 @@ Application::run(new class extends Application {
|
|||||||
"usage" => "-A|-a|-b",
|
"usage" => "-A|-a|-b",
|
||||||
|
|
||||||
"merge" => parent::ARGS,
|
"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",
|
["group",
|
||||||
["-A:", "--seta", "args" => "int", "name" => "a",
|
["-A:", "--seta", "args" => "int", "name" => "a",
|
||||||
"help" => "spécifier a",
|
"help" => "spécifier a",
|
||||||
@ -28,27 +43,19 @@ Application::run(new class extends Application {
|
|||||||
["-D::", "--override",
|
["-D::", "--override",
|
||||||
"help" => "++remplace celui de la section principale",
|
"help" => "++remplace celui de la section principale",
|
||||||
],
|
],
|
||||||
"sections" => [
|
["-1:first", "--one", "help" => "un argument"],
|
||||||
[
|
["-2:first,second", "--two", "help" => "deux arguments"],
|
||||||
"title" => "Section X",
|
["-3", "args" => ""],
|
||||||
"show" => false,
|
//["args" => [["value", "value"]], "name" => "args"],
|
||||||
["group",
|
//["args" => ["value", ["value"]], "name" => "args"],
|
||||||
["-X:", "--setx", "args" => "int", "name" => "x",
|
//["args" => ["value", "value"], "name" => "args"],
|
||||||
"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"],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
private ?int $a = null;
|
private ?int $a = null;
|
||||||
private ?int $x = null;
|
private ?int $x = null;
|
||||||
private ?string $override = null;
|
private ?string $override = null;
|
||||||
|
private ?string $one = null;
|
||||||
|
private ?array $two = null;
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
$profile = app::get_profile($productionMode);
|
$profile = app::get_profile($productionMode);
|
||||||
@ -63,6 +70,8 @@ Application::run(new class extends Application {
|
|||||||
"\na=", var_export($this->a, true),
|
"\na=", var_export($this->a, true),
|
||||||
"\nx=", var_export($this->x, true),
|
"\nx=", var_export($this->x, true),
|
||||||
"\noverride=", var_export($this->override, 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),
|
"\nargs=", var_export($this->args, true),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user