Skip to content

Commit

Permalink
Add flag to toggle between text and semantic diff
Browse files Browse the repository at this point in the history
  • Loading branch information
macmv committed Oct 7, 2024
1 parent d0791df commit c6fe4e3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/commands/schema/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export default class DiffSchemaCommand extends SchemaCommand {
description: "Compare the local schema to the active schema.",
default: false,
}),
text: Flags.boolean({
description: "Display the text diff instead of the semantic diff.",
default: false,
}),
};

static description = "Print the diff between local and remote schema.";
Expand Down Expand Up @@ -57,6 +61,7 @@ export default class DiffSchemaCommand extends SchemaCommand {
...(hasColor() ? { color: colorParam() } : {}),
staged: this.flags?.active ? "false" : "true",
...(version !== undefined ? { version } : { force: "true" }),
text_diff: this.flags?.text ? "true" : "false",
});
const res = await fetch(new URL(`/schema/1/validate?${params}`, url), {
method: "POST",
Expand Down Expand Up @@ -85,7 +90,11 @@ export default class DiffSchemaCommand extends SchemaCommand {
`Differences between the ${bold()}local${reset()} schema and the ${bold()}remote${reset()} schema:`
);
}
this.log(json.diff ? json.diff : "No schema differences");
if (this.flags?.text) {
this.log(json.text_diff ? json.text_diff : "No schema differences");
} else {
this.log(json.diff ? json.diff : "No schema differences");
}
} catch (err) {
this.error(err);
}
Expand Down

0 comments on commit c6fe4e3

Please sign in to comment.