mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-08 01:51:14 +00:00
fix: Improve CLI error handling, fix bash compat, and update cloud READMEs (#90)
- Show clear error when --prompt/-p or --prompt-file is used without a value (previously silently ignored) - Fix --prompt-file splice index bug when used after --prompt - Replace echo -e with printf in fly/lib/common.sh for macOS bash 3.x compatibility - Fix incorrect env var name in README (DIGITALOCEAN_TOKEN -> DO_API_TOKEN) - Add missing agent entries (gptme, OpenCode, Plandex) to 11 cloud READMEs - Add all 13 agents to Civo README (previously only had 3) Agent: ux-engineer Co-authored-by: A <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
66701d3cf9
commit
2915d7bca6
14 changed files with 260 additions and 10 deletions
|
|
@ -56,23 +56,33 @@ async function main(): Promise<void> {
|
|||
let prompt: string | undefined;
|
||||
let filteredArgs = [...args];
|
||||
|
||||
const promptIndex = args.findIndex(arg => arg === "--prompt" || arg === "-p");
|
||||
if (promptIndex !== -1 && args[promptIndex + 1]) {
|
||||
prompt = args[promptIndex + 1];
|
||||
const promptIndex = filteredArgs.findIndex(arg => arg === "--prompt" || arg === "-p");
|
||||
if (promptIndex !== -1) {
|
||||
if (!filteredArgs[promptIndex + 1] || filteredArgs[promptIndex + 1].startsWith("-")) {
|
||||
console.error(`Error: ${filteredArgs[promptIndex]} requires a value`);
|
||||
console.error(`\nUsage: spawn <agent> <cloud> ${filteredArgs[promptIndex]} "your prompt here"`);
|
||||
process.exit(1);
|
||||
}
|
||||
prompt = filteredArgs[promptIndex + 1];
|
||||
// Remove --prompt and its value from args
|
||||
filteredArgs.splice(promptIndex, 2);
|
||||
}
|
||||
|
||||
// Extract --prompt-file flag
|
||||
const promptFileIndex = args.findIndex(arg => arg === "--prompt-file");
|
||||
if (promptFileIndex !== -1 && args[promptFileIndex + 1]) {
|
||||
const promptFileIndex = filteredArgs.findIndex(arg => arg === "--prompt-file");
|
||||
if (promptFileIndex !== -1) {
|
||||
if (!filteredArgs[promptFileIndex + 1] || filteredArgs[promptFileIndex + 1].startsWith("-")) {
|
||||
console.error(`Error: --prompt-file requires a file path`);
|
||||
console.error(`\nUsage: spawn <agent> <cloud> --prompt-file instructions.txt`);
|
||||
process.exit(1);
|
||||
}
|
||||
const { readFileSync } = await import("fs");
|
||||
try {
|
||||
prompt = readFileSync(args[promptFileIndex + 1], "utf-8");
|
||||
prompt = readFileSync(filteredArgs[promptFileIndex + 1], "utf-8");
|
||||
// Remove --prompt-file and its value from args
|
||||
filteredArgs.splice(promptFileIndex, 2);
|
||||
} catch (err) {
|
||||
console.error(`Error reading prompt file '${args[promptFileIndex + 1]}': ${err && typeof err === "object" && "message" in err ? err.message : String(err)}`);
|
||||
console.error(`Error reading prompt file '${filteredArgs[promptFileIndex + 1]}': ${err && typeof err === "object" && "message" in err ? err.message : String(err)}`);
|
||||
console.error(`\nMake sure the file exists and is readable.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue