Skip to content

Commit 1662520

Browse files
committed
fix(image/generate): warn on file overwrite and respect --output json in quiet mode
1 parent e1ac016 commit 1662520

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/commands/image/generate.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,26 @@ export default defineCommand({
158158
for (let i = 0; i < imageUrls.length; i++) {
159159
const filename = `${prefix}_${String(i + 1).padStart(3, '0')}.jpg`;
160160
const destPath = join(outDir, filename);
161+
162+
// Warn if overwriting existing file (but don't block)
163+
if (existsSync(destPath)) {
164+
process.stderr.write(`Warning: overwriting existing file: ${destPath}\n`);
165+
}
166+
161167
await downloadFile(imageUrls[i]!, destPath, { quiet: config.quiet });
162168
saved.push(destPath);
163169
}
164170

165-
if (config.quiet) {
171+
// --output json is respected even in --quiet mode (JSON is the actual output, not progress)
172+
if (format === 'json') {
173+
console.log(formatOutput({
174+
id: response.data.task_id,
175+
saved,
176+
success_count: response.data.success_count,
177+
failed_count: response.data.failed_count,
178+
}, format));
179+
} else if (config.quiet) {
180+
// Non-JSON quiet mode: just print file paths
166181
console.log(saved.join('\n'));
167182
} else {
168183
console.log(formatOutput({

0 commit comments

Comments
 (0)