Skip to content

Add dry-run flag to fmt subcommand to check for unformatted files. - #361

Merged
Peefy merged 3 commits into
kcl-lang:mainfrom
f4z3r:feat/fmt-dry-run
Jul 29, 2026
Merged

Add dry-run flag to fmt subcommand to check for unformatted files.#361
Peefy merged 3 commits into
kcl-lang:mainfrom
f4z3r:feat/fmt-dry-run

Conversation

@f4z3r

@f4z3r f4z3r commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

2. What is the scope of this PR (e.g. component or file name):

The fmt subcommand.

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

Adds a --dry-run flag to the fmt subcommand. If provided, the command will return a non-zero status code if unformatted files are found. Moreover, it will print the following to stderr:

X KCL file(s) require formatting

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

@f4z3r

f4z3r commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Not sure the new e2e test will pass. I did not manage to get these working properly.

Signed-off-by: Jakob Beckmann <f4z3r-github@pm.me>
@f4z3r
f4z3r force-pushed the feat/fmt-dry-run branch from 794a500 to 12a59f0 Compare July 28, 2026 16:25
f4z3r added 2 commits July 29, 2026 09:45
Fixes kcl-lang/kcl#2101
Signed-off-by: Jakob Beckmann <f4z3r-github@pm.me>
Signed-off-by: Jakob Beckmann <f4z3r-github@pm.me>
@f4z3r
f4z3r force-pushed the feat/fmt-dry-run branch from 37316b1 to 81586fe Compare July 29, 2026 07:45
@f4z3r

f4z3r commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Not sure the new e2e test will pass. I did not manage to get these working properly.

Ok, the issue was due to a newline at the end of the input file that does not get sanitized. I am unsure if sanitation is desired, so I simply stripped it from the file.

@Peefy
Peefy merged commit 8959b81 into kcl-lang:main Jul 29, 2026
10 checks passed
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.

2 participants