Skip to content
Open
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
20 changes: 19 additions & 1 deletion src/Commando/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Command implements \ArrayAccess, \Iterator
$help = null,
$parsed = false,
$use_default_help = true,
$exit_after_help = true,
$trap_errors = true,
$beep_on_error = true,
$position = 0,
Expand Down Expand Up @@ -394,10 +395,25 @@ private function _file(Option $option, $require_exists = true, $allow_globbing =

/**
* @param bool $help
* @return Command
*/
public function useDefaultHelp($help = true)
{
$this->use_default_help = $help;
return $this;
}

/**
* Allows to bypass the default behavior of exit()ing after
* displaying the default help screen.
*
* @param bool $exit
* @return Command
*/
public function exitAfterHelp($exit)
{
$this->exit_after_help = $exit;
return $this;
}

/**
Expand Down Expand Up @@ -477,7 +493,9 @@ public function parse()
// Short circuit if the help flag was set and we're using default help
if ($this->use_default_help === true && $name === 'help') {
$this->printHelp();
exit;
if ($this->exit_after_help) {
exit;
}
}

$option = $this->getOption($name);
Expand Down