-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted version guessing logic and created new 'debug:guess-version…
…' command. (#103)
- Loading branch information
1 parent
5ce1258
commit ca2e3dd
Showing
8 changed files
with
420 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace Acquia\Orca\Console\Command\Debug; | ||
|
||
use Acquia\Orca\Composer\Composer; | ||
use Acquia\Orca\Console\Helper\StatusCode; | ||
use Acquia\Orca\Helper\Exception\OrcaException; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Provides a command. | ||
*/ | ||
class DebugGuessVersionCommand extends Command { | ||
|
||
/** | ||
* The default command name. | ||
* | ||
* @var string | ||
*/ | ||
protected static $defaultName = 'debug:guess-version'; | ||
|
||
/** | ||
* The Composer facade. | ||
* | ||
* @var \Acquia\Orca\Composer\Composer | ||
*/ | ||
private $composer; | ||
|
||
/** | ||
* Constructs an instance. | ||
* | ||
* @param \Acquia\Orca\Composer\Composer $composer | ||
* The Composer facade. | ||
*/ | ||
public function __construct(Composer $composer) { | ||
parent::__construct(self::$defaultName); | ||
$this->composer = $composer; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure(): void { | ||
$this | ||
->setAliases(['guess']) | ||
->setDescription('Displays ORCA environment variables') | ||
->addArgument('path', InputArgument::REQUIRED, 'The path to guess the version for'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
public function execute(InputInterface $input, OutputInterface $output): int { | ||
$path = $input->getArgument('path'); | ||
|
||
try { | ||
$guess = $this->composer->guessVersion($path); | ||
} | ||
catch (OrcaException $e) { | ||
$output->writeln("Error: {$e->getMessage()}"); | ||
return StatusCode::ERROR; | ||
} | ||
|
||
$output->writeln($guess); | ||
return StatusCode::OK; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.