Skip to content

Commit 1fad20c

Browse files
committed
Fixes an issue where options would not have defaults and dashes in parameters would break generation
1 parent c85f0b3 commit 1fad20c

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/Maker/MakeCommand.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
6565
->setHelp($this->getHelpFileContents('MakeCommand.txt'));
6666

6767
if ($this->supportsInvokableCommand()) {
68-
$command->addOption('invokable', 'i', InputOption::VALUE_NONE, 'Use this option to create an invokable command');
68+
$command->addOption('invokable', 'i', InputOption::VALUE_NEGATABLE, 'Use this option to create an invokable command', default: $this->supportsInvokableCommand());
6969
}
7070
}
7171

@@ -237,7 +237,7 @@ private function askForArguments(ConsoleStyle $io): array
237237
}
238238
}
239239

240-
return $name;
240+
return Str::asLowerCamelCase(strtr($name, ['-' => ' ']));
241241
});
242242

243243
if (!$name) {
@@ -295,7 +295,7 @@ private function askForOptions(ConsoleStyle $io): array
295295
}
296296
}
297297

298-
return $name;
298+
return Str::asLowerCamelCase(strtr($name, ['-' => ' ']));
299299
});
300300

301301
if (!$name) {
@@ -304,23 +304,23 @@ private function askForOptions(ConsoleStyle $io): array
304304

305305
$isFirst = false;
306306

307-
$shortcut = $io->ask('What is the option shortcut?', null);
307+
$shortcut = $io->ask('What is the option shortcut?');
308308
if (!\is_string($shortcut) && null !== $shortcut) {
309309
$shortcut = (string) $shortcut;
310310
}
311311

312312
$type = $io->choice(
313313
'What is the option type?',
314-
['bool', 'string', 'int', 'float', 'array'],
314+
['bool', 'string', 'int', 'float'],
315315
'bool'
316316
);
317317

318318
$options[] = [
319-
'name' => $name,
319+
'name' => Str::asLowerCamelCase($name),
320320
'shortcut' => $shortcut,
321321
'type' => $type,
322322
'description' => $this->askForParameterDescription($io),
323-
'default' => $this->askForDefaults($io, $type),
323+
'default' => $this->askForDefaults($io, $type, true),
324324
];
325325
}
326326

@@ -341,12 +341,14 @@ private function askForParameterDescription(ConsoleStyle $io): ?string
341341
return $description;
342342
}
343343

344-
private function askForDefaults(ConsoleStyle $io, string $type): mixed
344+
private function askForDefaults(ConsoleStyle $io, string $type, bool $force = false): mixed
345345
{
346-
$hasDefault = $io->confirm('Does it have a default value?', false);
346+
if (false === $force) {
347+
$hasDefault = $io->confirm('Does it have a default value?', false);
347348

348-
if (false === $hasDefault) {
349-
return null;
349+
if (false === $hasDefault) {
350+
return null;
351+
}
350352
}
351353

352354
if ('bool' === $type) {

0 commit comments

Comments
 (0)