Skip to content

Commit bc89442

Browse files
committed
feat: replace MultiSelectPrompt with MultiSearchPrompt for theme selection
1 parent 6bd630b commit bc89442

5 files changed

Lines changed: 31 additions & 18 deletions

File tree

phpstan.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ parameters:
55
level: 8
66
paths:
77
- src
8+
ignoreErrors:
9+
# Magento 2 auto-generated classes
10+
- '#[a-zA-Z0-9\\_]+Factory#'

src/Console/Command/Theme/BuildCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace OpenForgeProject\MageForge\Console\Command\Theme;
66

7-
use Laravel\Prompts\MultiSelectPrompt;
7+
use Laravel\Prompts\MultiSearchPrompt;
88
use Laravel\Prompts\Spinner;
99
use OpenForgeProject\MageForge\Console\Command\AbstractCommand;
1010
use OpenForgeProject\MageForge\Model\ThemeList;
@@ -82,11 +82,13 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
8282
// Set environment variables for Laravel Prompts
8383
$this->setPromptEnvironment();
8484

85-
$themeCodesPrompt = new MultiSelectPrompt(
85+
$themeCodesPrompt = new MultiSearchPrompt(
8686
label: 'Select themes to build',
87-
options: $options,
88-
default: [], // No default selection
89-
hint: 'Arrow keys to navigate, Space to toggle, Enter to confirm (scroll with arrows if needed)',
87+
options: fn(string $value) => empty($value)
88+
? $options
89+
: array_values(array_filter($options, fn($option) => stripos((string)$option, $value) !== false)),
90+
placeholder: 'Type to search theme...',
91+
hint: 'Type to search, arrow keys to navigate, Space to toggle, Enter to confirm',
9092
required: false,
9193
);
9294

src/Console/Command/Theme/CleanCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace OpenForgeProject\MageForge\Console\Command\Theme;
66

7-
use Laravel\Prompts\MultiSelectPrompt;
7+
use Laravel\Prompts\MultiSearchPrompt;
88
use Magento\Framework\Console\Cli;
99
use OpenForgeProject\MageForge\Console\Command\AbstractCommand;
1010
use OpenForgeProject\MageForge\Model\ThemeList;
@@ -187,11 +187,13 @@ private function promptForThemes(array $options, array $themes): ?array
187187
{
188188
$this->setPromptEnvironment();
189189

190-
$themeCodesPrompt = new MultiSelectPrompt(
190+
$themeCodesPrompt = new MultiSearchPrompt(
191191
label: 'Select themes to clean',
192-
options: $options,
193-
default: [],
194-
hint: 'Arrow keys to navigate, Space to toggle, Enter to confirm (scroll with arrows if needed)',
192+
options: fn(string $value) => empty($value)
193+
? $options
194+
: array_values(array_filter($options, fn($option) => stripos((string)$option, $value) !== false)),
195+
placeholder: 'Type to search theme...',
196+
hint: 'Type to search, arrow keys to navigate, Space to toggle, Enter to confirm',
195197
required: false,
196198
);
197199

src/Console/Command/Theme/TokensCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace OpenForgeProject\MageForge\Console\Command\Theme;
66

7-
use Laravel\Prompts\SelectPrompt;
7+
use Laravel\Prompts\SearchPrompt;
88
use Magento\Framework\Console\Cli;
99
use Magento\Framework\Filesystem\Driver\File;
1010
use Magento\Framework\Shell;
@@ -108,11 +108,14 @@ private function selectTheme(?string $themeCode): ?string
108108
$themes = $this->themeList->getAllThemes();
109109
$options = array_map(fn($theme) => $theme->getCode(), $themes);
110110

111-
$themeCodePrompt = new SelectPrompt(
111+
$themeCodePrompt = new SearchPrompt(
112112
label: 'Select theme to generate tokens for',
113-
options: $options,
113+
options: fn(string $value) => empty($value)
114+
? $options
115+
: array_values(array_filter($options, fn($option) => stripos((string)$option, $value) !== false)),
116+
placeholder: 'Type to search theme...',
114117
scroll: 10,
115-
hint: 'Arrow keys to navigate, Enter to confirm',
118+
hint: 'Type to search, arrow keys to navigate, Enter to confirm',
116119
);
117120

118121
try {

src/Console/Command/Theme/WatchCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace OpenForgeProject\MageForge\Console\Command\Theme;
66

7-
use Laravel\Prompts\SelectPrompt;
7+
use Laravel\Prompts\SearchPrompt;
88
use OpenForgeProject\MageForge\Console\Command\AbstractCommand;
99
use OpenForgeProject\MageForge\Model\ThemeList;
1010
use OpenForgeProject\MageForge\Model\ThemePath;
@@ -73,11 +73,14 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
7373
$options[] = $theme->getCode();
7474
}
7575

76-
$themeCodePrompt = new SelectPrompt(
76+
$themeCodePrompt = new SearchPrompt(
7777
label: 'Select theme to watch',
78-
options: $options,
78+
options: fn(string $value) => empty($value)
79+
? $options
80+
: array_values(array_filter($options, fn($option) => stripos((string)$option, $value) !== false)),
81+
placeholder: 'Type to search theme...',
7982
scroll: 10,
80-
hint: 'Arrow keys to navigate, Enter to confirm',
83+
hint: 'Type to search, arrow keys to navigate, Enter to confirm',
8184
);
8285

8386
$themeCode = $themeCodePrompt->prompt();

0 commit comments

Comments
 (0)