Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cli-commands/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function registerMediaCommands(root: Command, bind: CommandActionBinder):
.option("--aspect-ratio <RATIO>", "Choose the generated image aspect ratio")
.option("--quality <low|medium|high>", "Choose generation quality")
.option("--tag <TAG>", "Set the media tag")
.option("--no-progress", "Suppress stderr progress")
.action(bind(handleMediaGenerate)), CREDIT_HELP);

media.command("upload").description("Upload an image or video")
Expand Down
33 changes: 33 additions & 0 deletions src/media-generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,39 @@ test("media generate reports elapsed_ms and announces that it blocks", async ()
}
});

test("media generate --no-progress suppresses the notice while returning the generated media", async () => {
const transport = generateTransport();
const configDir = await testTemp("media-generate-no-progress-");
const fsLike = await enrolled(configDir);
try {
const result = await withRuntime(
["media", "generate", "--prompt", PROMPT, "--no-progress"],
transport,
{ configDir, fs: fsLike },
);
assert.equal(result.code, ExitCode.Success, result.stdout);
assert.equal(result.stderr, "");
const envelope = JSON.parse(result.stdout) as {
ok: boolean;
data: { media: { id: string }; usage: { credits: number; usd: string } };
};
assert.equal(envelope.ok, true);
assert.equal(envelope.data.media.id, GENERATED_MEDIA.id);
assert.equal(envelope.data.usage.credits, GENERATE_DEBITS.medium.credits);
assert.equal(envelope.data.usage.usd, GENERATE_DEBITS.medium.usd);
assert.equal(transport.calls.length, 1);
assert.equal(transport.calls[0]?.method, "POST");
assert.equal(transport.calls[0]?.path, "/api/v1/media/generations");
assert.deepEqual(transport.calls[0]?.body, {
prompt: PROMPT,
aspect_ratio: "16:9",
quality: "medium",
});
} finally {
await rm(configDir, { recursive: true, force: true });
}
});

test("a generate that times out says the still may exist and names the command that checks", async () => {
const transport = new FakeTransport().on("POST", "/api/v1/media/generations", () => {
throw timeoutError("API request timed out", "req_generatetimeout00000");
Expand Down
Loading