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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@decodo/cli",
"version": "0.1.8",
"version": "0.1.9",
"description": "Official CLI for the Decodo APIs",
"license": "MIT",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions src/scrape/services/command-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function addPropertyOption(

if (propertySchema.type === "boolean") {
command.option(`--${kebabFlag}`, help);
command.option(`--no-${kebabFlag}`, help);
return;
}

Expand Down
48 changes: 48 additions & 0 deletions tests/scrape/services/command-builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ describe("configureTargetCommand", () => {
expect(config.primaryField).toBe("product_id");
expect(command.registeredArguments).toHaveLength(1);
});

it("registers a --no-<flag> negation alongside boolean options", () => {
const command = new Command("universal");
configureTargetCommand(command, "universal", schema);

expect(command.options.some((opt) => opt.long === "--markdown")).toBe(true);
expect(command.options.some((opt) => opt.long === "--no-markdown")).toBe(
true
);
});
});

describe("buildScrapeBody", () => {
Expand Down Expand Up @@ -150,4 +160,42 @@ describe("buildScrapeBody", () => {
markdown: false,
});
});

it("lets --no-markdown send markdown: false for universal", () => {
const command = new Command("universal");
command.exitOverride();
const config = configureTargetCommand(command, "universal", schema);
command.action(() => undefined);

command.parse(["https://example.com", "--no-markdown"], { from: "user" });
expect(command.opts().markdown).toBe(false);

const body = buildScrapeBody(
"universal",
"https://example.com",
command.opts(),
config,
schema
);
expect(body.markdown).toBe(false);
});

it("keeps the markdown default when the flag is omitted for universal", () => {
const command = new Command("universal");
command.exitOverride();
const config = configureTargetCommand(command, "universal", schema);
command.action(() => undefined);

command.parse(["https://example.com"], { from: "user" });
expect(command.opts().markdown).toBeUndefined();

const body = buildScrapeBody(
"universal",
"https://example.com",
command.opts(),
config,
schema
);
expect(body.markdown).toBe(true);
});
});
Loading