Skip to content

feat: ktfmt argfile fix, output-mode option#22

Merged
Lauri "datafox" Heino (melodicore) merged 12 commits into
masterfrom
feat/ktfmt-argfile-output-mode
Jul 7, 2026
Merged

feat: ktfmt argfile fix, output-mode option#22
Lauri "datafox" Heino (melodicore) merged 12 commits into
masterfrom
feat/ktfmt-argfile-output-mode

Conversation

@melodicore

Copy link
Copy Markdown
Member

Summary

  • Fixes ktfmt argfile handling: flags are no longer written into the argfile alongside file paths; instead they are passed as elide flags directly, matching how other formatters work
  • Adds output-mode input (none | file | diff | command) to control what the action prints after formatting, using --list-files / --list-diffs flags added in elide v1.4.0
  • Adds output-mode-diffs input to cap the number of files whose diffs are printed (falls back to file listing if exceeded)
  • Adds output-mode-command input to print a custom fix command instead of a generated elide invocation
  • Adds files-failed action output (newline-separated file paths) populated when output-mode: file is set

- fix ktfmt to write only files to argfile; flags and extra args now go
  in exec args like javaformat (elide ktfmt now supports mixed args)
- add elideFlags parameter to buildFormatterArgs/runFormatter for flags
  that go before --; stdout is captured when elide flags are provided
- add output-mode option (none/file/diff/command) with post-run output:
  file prints affected paths, diff prints patch diffs, command prints a
  fix command using the listed files or a custom string
- add output-mode-diffs (integer limit for --list-diffs=N) and
  output-mode-command (custom command string for command mode)

Signed-off-by: melodicore <datafox@datafox.me>
- Fix output-mode=diff misparse when elide falls back to file listing
  (write mode, or --list-diffs=N limit exceeded): detect actual diff
  output via ---/+++/@@ markers and fall back to file-listing display
- Shell-quote file paths in command-mode suggestion
- Add files-failed action output (newline-separated affected files,
  populated in both check and write modes); only emitted when
  output-mode is file
- Update README: document new inputs, outputs, usage examples, remove
  stale skipped-directories sentence

Signed-off-by: melodicore <datafox@datafox.me>
Signed-off-by: melodicore <datafox@datafox.me>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the action’s formatter invocation to fix ktfmt argfile handling and adds a new output-mode feature set that controls what the action prints (file list, diffs, or a suggested fix command), plus a new files-failed output.

Changes:

  • Fix ktfmt argfile behavior by writing only file paths into the argfile and passing flags via the normal argument list.
  • Add output-mode / output-mode-diffs / output-mode-command inputs, and implement stdout parsing/printing helpers for list-files and list-diffs.
  • Add files-failed output and expand unit tests to cover new option parsing and output-mode behavior.

Reviewed changes

Copilot reviewed 8 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/options.ts Adds output-mode options, defaults, and input parsing helpers.
src/main.ts Implements output-mode flag selection, stdout parsing, printing, and files-failed output.
src/command.ts Changes formatter invocation to unify argfile handling and optionally capture stdout for output-mode.
README.md Documents new inputs/outputs and provides usage examples.
action.yml Adds new inputs and files-failed output metadata.
tests/options.test.ts Adds tests for output-mode normalization/defaults and new inputs.
tests/main.test.ts Adds tests for output-mode helpers and run() behavior with captured stdout.
tests/command.test.ts Updates tests for revised argfile behavior and added elide flags support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/command.ts
Comment thread src/options.ts
Signed-off-by: melodicore <datafox@datafox.me>
Signed-off-by: melodicore <datafox@datafox.me>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 10 changed files in this pull request and generated 2 comments.

Comment thread src/options.ts
Comment thread src/main.ts
Signed-off-by: melodicore <datafox@datafox.me>
Signed-off-by: melodicore <datafox@datafox.me>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.

Comment thread src/main.ts
Comment thread src/main.ts
Comment thread __tests__/main.test.ts
Signed-off-by: melodicore <datafox@datafox.me>
Signed-off-by: melodicore <datafox@datafox.me>
Signed-off-by: melodicore <datafox@datafox.me>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 13 changed files in this pull request and generated 1 comment.

Comment thread action.yml Outdated
Signed-off-by: melodicore <datafox@datafox.me>
Signed-off-by: melodicore <datafox@datafox.me>
@melodicore Lauri "datafox" Heino (melodicore) merged commit a99f939 into master Jul 7, 2026
2 checks passed
@melodicore Lauri "datafox" Heino (melodicore) deleted the feat/ktfmt-argfile-output-mode branch July 7, 2026 11:44
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