From 47270125539554bf4156c3ec2ead75a687b57afd Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 21 May 2025 17:55:56 +0100 Subject: [PATCH] Ask for name argument if empty --- src/Commands/OneTimeOperationsMakeCommand.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Commands/OneTimeOperationsMakeCommand.php b/src/Commands/OneTimeOperationsMakeCommand.php index 2927f6f..bce5e5f 100644 --- a/src/Commands/OneTimeOperationsMakeCommand.php +++ b/src/Commands/OneTimeOperationsMakeCommand.php @@ -8,7 +8,7 @@ class OneTimeOperationsMakeCommand extends OneTimeOperationsCommand { protected $signature = 'operations:make - {name : The name of the one-time operation} + {name? : The name of the one-time operation} {--e|essential : Create file without any attributes}'; protected $description = 'Create a new one-time operation'; @@ -23,7 +23,20 @@ protected function configure(): void public function handle(): int { try { - $file = OneTimeOperationCreator::createOperationFile($this->argument('name'), $this->option('essential')); + $name = $this->argument('name'); + + if (empty($name)) { + $name = $this->ask('What should the one-time operation be named?'); + + if (empty($name)) { + $this->components->error('The name cannot be empty.'); + + return self::FAILURE; + } + } + + $file = OneTimeOperationCreator::createOperationFile($name, $this->option('essential')); + $this->components->info(sprintf('One-time operation [%s] created successfully.', $file->getOperationName())); return self::SUCCESS;