Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 6ae174c

Browse files
committed
make sure option info only shows when there are options
1 parent 157b636 commit 6ae174c

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

core/lib/PatternLab/Console.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,25 +220,29 @@ public function writeHelpCommand($command = "") {
220220
// write out the generic usage info
221221
$this->writeLine($commandLongUC." Command Options",true);
222222
$this->writeLine("Usage:");
223-
$this->writeLine(" php ".$this->self." --".$commandLong." ".$optionList,true);
224-
$this->writeLine("Available options:");
223+
$this->writeLine(" php ".$this->self." --".$commandLong."|-".$commandShort." ".$optionList,true);
225224

226-
// write out the options
227-
foreach ($commandOptions as $option => $attributes) {
228-
$spacer = $this->getSpacer($lengthLong,$attributes["optionLongLength"]);
229-
$this->writeLine(" --".$attributes["optionLong"].$spacer."(-".$attributes["optionShort"].") ".$attributes["optionDesc"]);
225+
// write out the available options
226+
if (count($commandOptions) > 0) {
227+
$this->writeLine("Available options:");
228+
foreach ($commandOptions as $option => $attributes) {
229+
$spacer = $this->getSpacer($lengthLong,$attributes["optionLongLength"]);
230+
$this->writeLine(" --".$attributes["optionLong"].$spacer."(-".$attributes["optionShort"].") ".$attributes["optionDesc"]);
231+
}
232+
$this->writeLine("");
230233
}
231234

232-
$this->writeLine("");
233235
$this->writeLine("Help:");
234236
$this->writeLine(" ".$commandHelp,true);
235-
$this->writeLine(" Samples:",true);
236237

237238
// write out the samples
238-
foreach ($commandOptions as $option => $attributes) {
239-
$this->writeLine(" ".$attributes["optionSample"]);
240-
$this->writeLine(" php ".$this->self." --".$commandLong." --".$attributes["optionLong"]);
241-
$this->writeLine(" php ".$this->self." -".$commandShort." -".$attributes["optionShort"],true);
239+
if (count($commandOptions) > 0) {
240+
$this->writeLine(" Samples:",true);
241+
foreach ($commandOptions as $option => $attributes) {
242+
$this->writeLine(" ".$attributes["optionSample"]);
243+
$this->writeLine(" php ".$this->self." --".$commandLong." --".$attributes["optionLong"]);
244+
$this->writeLine(" php ".$this->self." -".$commandShort." -".$attributes["optionShort"],true);
245+
}
242246
}
243247

244248
}

0 commit comments

Comments
 (0)