You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Toolkit] Improve InstallComponentCommand by asking/guessing which Kit to use, remove ux_toolkit.kit parameter, remove DependencyInjection configuration
// If more than one kit is available, we ask the user which one to use
112
+
if (($availableKitsCount = \count($availableKits)) > 1) {
113
+
$kitName = $io->choice(null === $componentName ? 'Which kit do you want to use?' : \sprintf('The component "%s" exists in multiple kits. Which one do you want to use?', $componentName), array_map(fn (Kit$kit) => $kit->name, $availableKits));
114
+
115
+
foreach ($availableKitsas$availableKit) {
116
+
if ($availableKit->name === $kitName) {
117
+
$kit = $availableKit;
118
+
break;
119
+
}
120
+
}
121
+
} elseif (1 === $availableKitsCount) {
122
+
$kit = $availableKits[0];
123
+
} else {
124
+
$io->error(null === $componentName
125
+
? 'It seems that no local kits are available and it should not happens. Please open an issue on https://github.com/symfony/ux to report this.'
126
+
: sprintf("The component \"%s\" does not exist in any local kits.\n\nYou can try to run one of the following commands to interactively install components:\n%s\n\nOr you can try one of the community kits https://github.com/search?q=topic:ux-toolkit&type=repositories", $componentName, implode("\n", array_map(fn (string$availableKitName) => sprintf('$ bin/console %s --kit %s', $this->getName(), $availableKitName), $availableKitNames)))
if (null === $componentName = $input->getArgument('component')) {
136
+
if (null === $componentName) {
99
137
// Ask for the component name if not provided
100
138
$componentName = $io->choice('Which component do you want to install?', array_map(fn (Component$component) => $component->name, $this->getAvailableComponents($kit)));
101
139
$component = $kit->getComponent($componentName);
@@ -124,7 +162,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
124
162
}
125
163
}
126
164
127
-
$io->writeln(\sprintf('Installing component <info>%s</> from the <info>%s</> kit...', $component->name, $kitName));
165
+
$io->writeln(\sprintf('Installing component <info>%s</> from the <info>%s</> kit...', $component->name, $kit->name));
0 commit comments