Skip to content

Commit

Permalink
[10.x] Mark commands as isolatable (laravel#46925)
Browse files Browse the repository at this point in the history
* Ability to set default for --isolated option

* set default exit code

* Update Command.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
bytestream and taylorotwell authored May 1, 2023
1 parent 812ef55 commit 8de1aa2
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ class Command extends SymfonyCommand
*/
protected $hidden = false;

/**
* Indicates whether only one instance of the command can run at any given time.
*
* @var bool
*/
protected $isolated = false;

/**
* The default exit code for isolated commands.
*
* @var int
*/
protected $isolatedExitCode = self::SUCCESS;

/**
* The console command name aliases.
*
Expand Down Expand Up @@ -140,7 +154,7 @@ protected function configureIsolation()
null,
InputOption::VALUE_OPTIONAL,
'Do not run the command if another instance of the command is already running',
false
$this->isolated
));
}

Expand Down Expand Up @@ -185,7 +199,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

return (int) (is_numeric($this->option('isolated'))
? $this->option('isolated')
: self::SUCCESS);
: $this->isolatedExitCode);
}

$method = method_exists($this, 'handle') ? 'handle' : '__invoke';
Expand Down

0 comments on commit 8de1aa2

Please sign in to comment.