mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-26 19:54:46 +01:00
LScli :: usage() : only show current executed command message (if already specified)
This commit is contained in:
parent
83b64aac87
commit
fe4ef419fd
1 changed files with 6 additions and 1 deletions
|
@ -30,6 +30,9 @@ class LScli {
|
||||||
// Configured commands
|
// Configured commands
|
||||||
private static $commands = array();
|
private static $commands = array();
|
||||||
|
|
||||||
|
// Store current executed command
|
||||||
|
private static $current_command = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a CLI command
|
* Add a CLI command
|
||||||
*
|
*
|
||||||
|
@ -87,6 +90,8 @@ class LScli {
|
||||||
echo "Available commands :\n";
|
echo "Available commands :\n";
|
||||||
|
|
||||||
foreach (self :: $commands as $command => $info) {
|
foreach (self :: $commands as $command => $info) {
|
||||||
|
if (self :: $current_command and self :: $current_command != $command)
|
||||||
|
continue;
|
||||||
echo " $command : ".$info['short_desc']."\n";
|
echo " $command : ".$info['short_desc']."\n";
|
||||||
echo " ".basename($argv[0])." $command ".($info['usage_args']?$info['usage_args']:'')."\n";
|
echo " ".basename($argv[0])." $command ".($info['usage_args']?$info['usage_args']:'')."\n";
|
||||||
if ($info['long_desc']) {
|
if ($info['long_desc']) {
|
||||||
|
@ -117,7 +122,7 @@ class LScli {
|
||||||
for ($i=1; $i < count($argv); $i++) {
|
for ($i=1; $i < count($argv); $i++) {
|
||||||
if (array_key_exists($argv[$i], self :: $commands)) {
|
if (array_key_exists($argv[$i], self :: $commands)) {
|
||||||
if (!$command)
|
if (!$command)
|
||||||
$command = $argv[$i];
|
self :: $current_command = $command = $argv[$i];
|
||||||
else
|
else
|
||||||
self :: usage(_("Only one command could be executed !"));
|
self :: usage(_("Only one command could be executed !"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue