Skip to content

Commit

Permalink
refactor(Generators): update BitoCliGenerator to improve process hand…
Browse files Browse the repository at this point in the history
…ling

- 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.
  • Loading branch information
[email protected] committed Oct 13, 2024
1 parent f508c90 commit a3c1e2d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/Generators/BitoCliGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public function __construct(array $config)
*/
public function generate(string $prompt): string
{
file_put_contents($promptFile = ConfigManager::globalPath($this->config['prompt_filename']), $prompt);

return resolve(
Process::class,
['command' => [$this->config['path'], '-p', $promptFile]] + $this->config['parameters']
)->mustRun(function (string $type, string $data): void {
Process::OUT === $type ? $this->outputStyle->write($data) : $this->outputStyle->write("<fg=red>$data</>");
})->getOutput();
// file_put_contents($promptFile = ConfigManager::globalPath($this->config['prompt_filename']), $prompt);

return resolve(Process::class, ['command' => [$this->config['path']]] + $this->config['parameters'])
->setInput($prompt)
->mustRun(function (string $type, string $data): void {
Process::OUT === $type ? $this->outputStyle->write($data) : $this->outputStyle->write("<fg=red>$data</>");
})
->getOutput();
}
}

0 comments on commit a3c1e2d

Please sign in to comment.