Skip to content

Commit 6953933

Browse files
dahliacodex
andcommitted
Print exactly one separator between printed lookup objects
Emit separators only before each printed object after the first to avoid duplicate separators in multi-object lookup output. Ref: #608 (comment) Co-Authored-By: OpenAI Codex <codex@openai.com>
1 parent ad436e6 commit 6953933

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

packages/cli/src/lookup.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -839,11 +839,9 @@ export async function runLookup(
839839

840840
spinner.stop();
841841
let success = true;
842-
let i = 0;
843-
for (const obj of objects) {
842+
let printedCount = 0;
843+
for (const [i, obj] of objects.entries()) {
844844
const url = command.urls[i];
845-
if (i > 0) console.log(command.separator);
846-
i++;
847845
if (obj == null) {
848846
spinner.fail(`Failed to fetch ${colors.red(url)}`);
849847
if (authLoader == null) {
@@ -854,15 +852,14 @@ export async function runLookup(
854852
success = false;
855853
} else {
856854
spinner.succeed(`Fetched object: ${colors.green(url)}`);
855+
if (printedCount > 0) console.log(command.separator);
857856
await writeObjectToStream(
858857
obj,
859858
command.output,
860859
command.format,
861860
contextLoader,
862861
);
863-
if (i < command.urls.length - 1) {
864-
console.log(command.separator);
865-
}
862+
printedCount++;
866863
}
867864
}
868865
if (success) {

0 commit comments

Comments
 (0)