Skip to content

fix: allow generated boolean options to be set to false - #59

Open
anilonayy wants to merge 2 commits into
Dokploy:mainfrom
anilonayy:fix/boolean-flags-false
Open

anilonayy wants to merge 2 commits into
Dokploy:mainfrom
anilonayy:fix/boolean-flags-false

Conversation

@anilonayy

Copy link
Copy Markdown

Fixes #58

Problem

Generated boolean options are bare flags (--autoDeploy), so they can only send true. There's no way to turn a setting off from the CLI:

dokploy application update --applicationId <id> --autoDeploy false
# error: too many arguments for 'update'. Expected 0 arguments but got 1.
dokploy application update --applicationId <id> --no-autoDeploy
# error: unknown option '--no-autoDeploy'

Required boolean inputs (e.g. application save-environment --createEnvFile, --isEnabled, --enabled) are worse: the flag is mandatory, so those commands can only ever send true.

Fix

generateOptionLine in scripts/generate.ts now also emits commander's negated flag for every boolean field:

.option('--autoDeploy', 'autoDeploy')
.option('--no-autoDeploy', 'set autoDeploy to false')

When both --x and --no-x are defined, commander leaves the value undefined if neither is passed. So omitted booleans are still not sent, and partial updates don't overwrite unrelated settings. --x keeps its current meaning (true), so existing scripts are unaffected. The existing boolean coercion already handles false. For required booleans, --no-x satisfies the requirement.

src/generated/commands.ts was regenerated with pnpm run generate. That also picks up compose update --pullImages, which was already in openapi.json but hadn't been regenerated yet.

Testing

  • New tests/boolean-flags.test.ts runs the built CLI against a local HTTP server and checks the request body:
    • --autoDeploy → autoDeploy: true
    • --no-autoDeploy --no-cleanCache → both false
    • only --name → no boolean keys in the payload
    • --help lists --no-autoDeploy
  • pnpm run build and pnpm test (22/22) pass. biome lint is clean on the changed files and biome check is clean on the new test file. scripts/generate.ts has formatter diffs that are already on main; I left them alone to keep this diff small.
  • A required boolean accepts the negated flag: application save-environment ... --no-createEnvFile gets past option parsing, while leaving the flag out still fails with required option '--createEnvFile' not specified.

@anilonayy
anilonayy force-pushed the fix/boolean-flags-false branch from 240e743 to ccaaaf7 Compare October 12, 2026 00:19
@anilonayy

Copy link
Copy Markdown
Author

Hi @Siumauricio, friendly ping on this one when you have a moment. It fixes #58 (generated boolean options couldn't be set to false), adds --no-<flag> handling, and the test suite passes. Branch is up to date and mergeable. Happy to adjust anything.

@anilonayy

Copy link
Copy Markdown
Author

Hi @Siumauricio, following up on this. It is still mergeable and fixes #58. Happy to adjust the --no-<flag> approach if you would prefer something different.

@imrja8

imrja8 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

@anilonayy solve conflicts

…alse

# Conflicts:
#	src/generated/commands.ts

Copy link
Copy Markdown
Author

@imrja8 conflicts are resolved. The branch is now up to date with main, the PR is mergeable, and all 59 tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated boolean options can only be set to true (no way to send false)

2 participants