diff --git a/src/Command/App/NewFromDrupal7Command.php b/src/Command/App/NewFromDrupal7Command.php index 73d920af6..7cf30ec2d 100644 --- a/src/Command/App/NewFromDrupal7Command.php +++ b/src/Command/App/NewFromDrupal7Command.php @@ -43,7 +43,7 @@ class NewFromDrupal7Command extends CommandBase { protected function configure(): void { $this->setDescription('Generate a new Drupal 9+ project from a Drupal 7 application using the default Acquia Migrate Accelerate recommendations.') - ->addOption('drupal7-directory', 'source', InputOption::VALUE_OPTIONAL, 'The root of the Drupal 7 application.') + ->addOption('drupal7-directory', 'source', InputOption::VALUE_OPTIONAL, 'The root of the Drupal 7 application') ->addOption('drupal7-uri', 'uri', InputOption::VALUE_OPTIONAL, 'Only necessary in case of a multisite. If a single site, this will be computed automatically.') ->addOption('stored-analysis', 'analysis', InputOption::VALUE_OPTIONAL, 'As an alternative to drupal7-directory, it is possible to pass a stored analysis.') ->addOption('recommendations', 'recommendations', InputOption::VALUE_OPTIONAL, 'Overrides the default recommendations.') @@ -66,15 +66,7 @@ private function getInspector(InputInterface $input): SiteInspectorInterface { } // First: Determine the Drupal 7 root. - if ($input->getOption('drupal7-directory') === NULL) { - $answer = $this->io->ask( - 'What is the root of the Drupal 7 application you want to generate a new Drupal project for?', - NULL, - [Drupal7SiteInspector::class, 'validateDrupal7Root'], - ); - $input->setOption('drupal7-directory', $answer); - } - $d7_root = $input->getOption('drupal7-directory'); + $d7_root = $this->determineOption('drupal7-directory', FALSE, Drupal7SiteInspector::validateDrupal7Root(...), NULL, '.'); // Second, determine which "sites" subdirectory is being assessed. $uri = Drupal7SiteInspector::getSiteUri($input, $d7_root); diff --git a/src/Command/CommandBase.php b/src/Command/CommandBase.php index 3be9d57e0..befa25f84 100644 --- a/src/Command/CommandBase.php +++ b/src/Command/CommandBase.php @@ -1327,7 +1327,7 @@ protected function promptOpenBrowserToCreateToken( } protected function determineApiKey(): string { - return $this->determineOption('key', FALSE, Closure::fromCallable([$this, 'validateApiKey'])); + return $this->determineOption('key', FALSE, $this->validateApiKey(...)); } private function validateApiKey(mixed $key): string { @@ -1343,7 +1343,7 @@ private function validateApiKey(mixed $key): string { } protected function determineApiSecret(): string { - return $this->determineOption('secret', TRUE, Closure::fromCallable([$this, 'validateApiKey'])); + return $this->determineOption('secret', TRUE, $this->validateApiKey(...)); } /** diff --git a/src/Command/Ide/IdeCreateCommand.php b/src/Command/Ide/IdeCreateCommand.php index 94cbe5d65..3b46a7c71 100644 --- a/src/Command/Ide/IdeCreateCommand.php +++ b/src/Command/Ide/IdeCreateCommand.php @@ -40,7 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $accountResource = new Account($acquiaCloudClient); $account = $accountResource->get(); $default = "$account->first_name $account->last_name's IDE"; - $ideLabel = $this->determineOption('label', FALSE, \Closure::fromCallable([$this, 'validateIdeLabel']), NULL, $default); + $ideLabel = $this->determineOption('label', FALSE, $this->validateIdeLabel(...), NULL, $default); // Create it. $checklist->addItem('Creating your Cloud IDE'); diff --git a/src/Command/Ssh/SshKeyCommandBase.php b/src/Command/Ssh/SshKeyCommandBase.php index 6753b5113..60075750a 100644 --- a/src/Command/Ssh/SshKeyCommandBase.php +++ b/src/Command/Ssh/SshKeyCommandBase.php @@ -11,7 +11,6 @@ use AcquiaCloudApi\Connector\Client; use AcquiaCloudApi\Endpoints\SshKeys; use AcquiaCloudApi\Response\IdeResponse; -use Closure; use React\EventLoop\Loop; use RuntimeException; use Symfony\Component\Console\Output\OutputInterface; @@ -247,7 +246,7 @@ protected function determineFilename(): string { return $this->determineOption( 'filename', FALSE, - Closure::fromCallable([$this, 'validateFilename']), + $this->validateFilename(...), static function (mixed $value) { return $value ? trim($value) : '';}, 'id_rsa_acquia' @@ -271,7 +270,7 @@ protected function determinePassword(): string { return $this->determineOption( 'password', TRUE, - Closure::fromCallable([$this, 'validatePassword']), + $this->validatePassword(...), static function (mixed $value) { return $value ? trim($value) : ''; } @@ -344,7 +343,7 @@ private function promptChooseLocalSshKey(array $localKeys): string { } protected function determineSshKeyLabel(): string { - return $this->determineOption('label', FALSE, Closure::fromCallable([$this, 'validateSshKeyLabel']), Closure::fromCallable([$this, 'normalizeSshKeyLabel'])); + return $this->determineOption('label', FALSE, $this->validateSshKeyLabel(...), $this->normalizeSshKeyLabel(...)); } private function validateSshKeyLabel(mixed $label): mixed {