From fe4ef419fd0ca83eeb54243d2c34f9fdbd6ba9fc Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 6 May 2020 17:46:08 +0200 Subject: [PATCH] LScli :: usage() : only show current executed command message (if already specified) --- src/includes/class/class.LScli.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/includes/class/class.LScli.php b/src/includes/class/class.LScli.php index 8d9b0ab6..94bdd88c 100644 --- a/src/includes/class/class.LScli.php +++ b/src/includes/class/class.LScli.php @@ -30,6 +30,9 @@ class LScli { // Configured commands private static $commands = array(); + // Store current executed command + private static $current_command = null; + /** * Add a CLI command * @@ -87,6 +90,8 @@ class LScli { echo "Available commands :\n"; foreach (self :: $commands as $command => $info) { + if (self :: $current_command and self :: $current_command != $command) + continue; echo " $command : ".$info['short_desc']."\n"; echo " ".basename($argv[0])." $command ".($info['usage_args']?$info['usage_args']:'')."\n"; if ($info['long_desc']) { @@ -117,7 +122,7 @@ class LScli { for ($i=1; $i < count($argv); $i++) { if (array_key_exists($argv[$i], self :: $commands)) { if (!$command) - $command = $argv[$i]; + self :: $current_command = $command = $argv[$i]; else self :: usage(_("Only one command could be executed !")); }