Skip to content

Commit e913b45

Browse files
committed
Refactor InstallCommand to reorder bootstrap invocation
Signed-off-by: Pushpak Chhajed <[email protected]>
1 parent c6f315c commit e913b45

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

src/Console/InstallCommand.php

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,13 @@ public function handle(
7979
Herd $herd,
8080
Terminal $terminal,
8181
): int {
82-
$this->bootstrap($codeEnvironmentsDetector, $herd, $terminal);
83-
8482
[$guidelines, $mcp] = $this->validateOptions();
8583

8684
if ($guidelines === false && $mcp === false) {
8785
return self::FAILURE;
8886
}
8987

88+
$this->bootstrap($codeEnvironmentsDetector, $herd, $terminal);
9089
$this->displayBoostHeader();
9190
$this->discoverEnvironment();
9291
$this->collectInstallationPreferences($guidelines, $mcp);
@@ -96,23 +95,6 @@ public function handle(
9695
return self::SUCCESS;
9796
}
9897

99-
protected function bootstrap(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $herd, Terminal $terminal): void
100-
{
101-
$this->codeEnvironmentsDetector = $codeEnvironmentsDetector;
102-
$this->herd = $herd;
103-
$this->terminal = $terminal;
104-
105-
$this->terminal->initDimensions();
106-
107-
$this->greenTick = $this->green('');
108-
$this->redCross = $this->red('');
109-
110-
$this->selectedTargetAgents = collect();
111-
$this->selectedTargetMcpClient = collect();
112-
113-
$this->projectName = config('app.name');
114-
}
115-
11698
/**
11799
* @return array{bool, bool}
118100
*/
@@ -130,6 +112,23 @@ protected function validateOptions(): array
130112
return [$guidelines, $mcp];
131113
}
132114

115+
protected function bootstrap(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $herd, Terminal $terminal): void
116+
{
117+
$this->codeEnvironmentsDetector = $codeEnvironmentsDetector;
118+
$this->herd = $herd;
119+
$this->terminal = $terminal;
120+
121+
$this->terminal->initDimensions();
122+
123+
$this->greenTick = $this->green('');
124+
$this->redCross = $this->red('');
125+
126+
$this->selectedTargetAgents = collect();
127+
$this->selectedTargetMcpClient = collect();
128+
129+
$this->projectName = config('app.name');
130+
}
131+
133132
protected function displayBoostHeader(): void
134133
{
135134
note($this->boostLogo());
@@ -168,7 +167,7 @@ protected function collectInstallationPreferences(bool $guidelines, bool $mcp):
168167
protected function performInstallation(bool $guidelines, bool $mcp): void
169168
{
170169
if ($guidelines) {
171-
$this->installGuidelines();
170+
$this->installGuidelines($mcp);
172171
}
173172

174173
usleep(750000);
@@ -419,7 +418,7 @@ protected function selectCodeEnvironments(string $contractClass, string $label,
419418
)->filter()->values();
420419
}
421420

422-
protected function installGuidelines(): void
421+
protected function installGuidelines(bool $mcp): void
423422
{
424423
if ($this->selectedTargetAgents->isEmpty()) {
425424
$this->info(' No agents selected for guideline installation.');
@@ -483,17 +482,19 @@ protected function installGuidelines(): void
483482
}
484483
}
485484

486-
$this->config->setSail(
487-
$this->shouldUseSail()
488-
);
485+
if ($mcp) {
486+
$this->config->setSail(
487+
$this->shouldUseSail()
488+
);
489489

490-
$this->config->setHerdMcp(
491-
$this->shouldInstallHerdMcp()
492-
);
490+
$this->config->setHerdMcp(
491+
$this->shouldInstallHerdMcp()
492+
);
493493

494-
$this->config->setEditors(
495-
$this->selectedTargetMcpClient->map(fn (McpClient $mcpClient): string => $mcpClient->name())->values()->toArray()
496-
);
494+
$this->config->setEditors(
495+
$this->selectedTargetMcpClient->map(fn (McpClient $mcpClient): string => $mcpClient->name())->values()->toArray()
496+
);
497+
}
497498

498499
$this->config->setAgents(
499500
$this->selectedTargetAgents->map(fn (Agent $agent): string => $agent->name())->values()->toArray()

0 commit comments

Comments
 (0)