Skip to content

Commit

Permalink
Improved exit codes for reactor commands
Browse files Browse the repository at this point in the history
  • Loading branch information
freost committed Nov 15, 2024
1 parent aee6def commit 67b620f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 53 deletions.
10 changes: 10 additions & 0 deletions src/mako/reactor/CommandInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ interface CommandInterface
*/
public const int STATUS_ERROR = 1;

/**
* Incorrect usage status code.
*/
public const int STATUS_INCORRECT_USAGE = 2;

/**
* Unknown command status code.
*/
public const int STATUS_UNKNOWN_COMMAND = 127;

/**
* Returns the command.
*
Expand Down
4 changes: 2 additions & 2 deletions src/mako/reactor/Reactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ protected function unknownCommand(string $command): int

$this->listCommands();

return CommandInterface::STATUS_ERROR;
return CommandInterface::STATUS_UNKNOWN_COMMAND;
}

/**
Expand Down Expand Up @@ -375,7 +375,7 @@ public function run(): int
catch (ArgumentException|UnexpectedValueException $e) {
$this->output->errorLn("<red>{$e->getMessage()}</red>");

return CommandInterface::STATUS_ERROR;
return CommandInterface::STATUS_INCORRECT_USAGE;
}
}
}
Loading

0 comments on commit 67b620f

Please sign in to comment.