Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Commando/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,16 @@ public function parse()
// todo protect against duplicates caused by aliases
foreach ($this->options as $option) {
if (is_null($option->getValue()) && $option->isRequired()) {
throw new \Exception(sprintf('Required %s %s must be specified',
$option->getType() & Option::TYPE_NAMED ?
'option' : 'argument', $option->getName()));
$name = $option->getName();
if ($option->getType() & Option::TYPE_NAMED) {
$nature = 'option';
} else {
$nature = 'argument';
if ($title = $option->getTitle()) {
$name = $title;
}
}
throw new \Exception(sprintf('Required %s %s must be specified', $nature, $name));
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/Commando/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,14 @@ public function getAliases()
return $this->aliases;
}

/**
* @return string title of the option
*/
public function getTitle()
{
return $this->title;
}

/**
* Get the current set of this option's requirements
* @return string[] List of required options
Expand Down