Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve --typechecked help text #544

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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 src/commands/database/create.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function buildCreateCommand(yargs) {
typechecked: {
type: "boolean",
description:
"Enable typechecking for the database. Defaults to the typechecking setting of the parent database.",
"Enable typechecking for the database. Use --no-typechecked to disable. Defaults to enabled for top-level databases. Inherits the parent database's setting for child databases.",
},
protected: {
type: "boolean",
Expand Down
16 changes: 13 additions & 3 deletions src/commands/local.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@
color,
}),
);

// In the docker container, typechecked will be false by default if not set.
// We need to set it to true if it's not set. We can't do it in the options,
// because we don't want to validate it unless --database is set.
let typechecked = argv.typechecked;
if (argv.database && argv.typechecked === undefined) {
typechecked = true;
}

try {
const db = await runQuery({
secret: "secret",
Expand All @@ -78,7 +87,7 @@
let name = ${argv.database}
let database = Database.byName(name)
let protected = ${argv.protected ?? null}
let typechecked = ${argv.typechecked ?? null}
let typechecked = ${typechecked}
let priority = ${argv.priority ?? null}
if (database == null) {
Database.create({
Expand Down Expand Up @@ -167,8 +176,9 @@
},
typechecked: {
describe:
"Enable typechecking for the database. Valid only if --database is set.",
"Enable typechecking for the database. Use --no-typechecked to disable. Valid only if --database is set.",
jrodewig marked this conversation as resolved.
Show resolved Hide resolved
type: "boolean",
default: undefined,
},
protected: {
describe:
Expand Down Expand Up @@ -198,7 +208,7 @@
type: "boolean",
},
})
.check((argv) => {

Check warning on line 211 in src/commands/local.mjs

View workflow job for this annotation

GitHub Actions / lint

Arrow function has a complexity of 11. Maximum allowed is 10
if (argv.maxAttempts < 1) {
throw new ValidationError("--max-attempts must be greater than 0.");
}
Expand All @@ -207,7 +217,7 @@
"--interval must be greater than or equal to 0.",
);
}
if (argv.typechecked && !argv.database) {
if (argv.typechecked !== undefined && !argv.database) {
throw new ValidationError(
"--typechecked can only be set if --database is set.",
);
Expand Down
Loading