Improve CLI usage message format

This commit is contained in:
Benjamin Renard 2021-10-07 20:49:07 +02:00
parent e26da38457
commit 6684efab2f

View file

@ -42,7 +42,7 @@ function usage($error=false) {
if ($error)
echo "$error\n\n";
printf(_("Usage: %s [-h] [-qd] command\n"), $argv[0]);
printf(_("Usage: %s [-h] [-qd] command\n"), basename($argv[0]));
echo _(" -h Show this message\n");
echo _(" -q / -d Quiet/Debug mode\n");
echo _(" --trace Trace mode (the most verbose)\n");
@ -53,8 +53,8 @@ function usage($error=false) {
foreach ($cli_commands as $command => $info) {
if ($cli_command && $command != $cli_command)
continue;
echo " $command: "._($info['short_desc'])."\n";
echo " ".$argv[0]." $command ".($info['usage_args']?_($info['usage_args']):'')."\n";
echo " ".str_replace("\n", "\n ", wordwrap("$command : "._($info['short_desc'])))."\n\n";
echo " ".basename($argv[0])." $command ".($info['usage_args']?_($info['usage_args']):'')."\n";
if ($info['long_desc']) {
if (is_array($info['long_desc'])) {
$lines = array();