Skip to content

Make command ask for name argument if it's empty #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/Commands/OneTimeOperationsMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down