Skip to content

Commit a3c1e2d

Browse files
author
ityaozm@gmail.com
committed
refactor(Generators): update BitoCliGenerator to improve process handling
- Remove file writing operation for prompt file. - Modify command resolution to use parameters directly. - Set input for the process instead of using a temporary file. - Enhance output handling by maintaining color coding for different output types.
1 parent f508c90 commit a3c1e2d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

app/Generators/BitoCliGenerator.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public function __construct(array $config)
4040
*/
4141
public function generate(string $prompt): string
4242
{
43-
file_put_contents($promptFile = ConfigManager::globalPath($this->config['prompt_filename']), $prompt);
44-
45-
return resolve(
46-
Process::class,
47-
['command' => [$this->config['path'], '-p', $promptFile]] + $this->config['parameters']
48-
)->mustRun(function (string $type, string $data): void {
49-
Process::OUT === $type ? $this->outputStyle->write($data) : $this->outputStyle->write("<fg=red>$data</>");
50-
})->getOutput();
43+
// file_put_contents($promptFile = ConfigManager::globalPath($this->config['prompt_filename']), $prompt);
44+
45+
return resolve(Process::class, ['command' => [$this->config['path']]] + $this->config['parameters'])
46+
->setInput($prompt)
47+
->mustRun(function (string $type, string $data): void {
48+
Process::OUT === $type ? $this->outputStyle->write($data) : $this->outputStyle->write("<fg=red>$data</>");
49+
})
50+
->getOutput();
5151
}
5252
}

0 commit comments

Comments
 (0)