ktfmt icon indicating copy to clipboard operation
ktfmt copied to clipboard

Feature request: ability to specify file of files to format

Open ZacSweers opened this issue 2 years ago • 4 comments

If you try to run ktfmt's CLI over the find output of a large codebase, you can eventually exceed the maximum number of arguments. It would be great if these could be stored in a file and fed to the CLI via alternative parameter.

tooling/scripts/format.sh: line 23: ./config/bin/ktfmt: Argument list too long

ZacSweers avatar Jan 10 '23 06:01 ZacSweers

As a workaround, does something like the following work?

find $DIR -name \*.kt | xargs tooling/scripts/format.sh

cgrushko avatar Jan 10 '23 07:01 cgrushko

Sorry for the delay! That does indeed work 👍

ZacSweers avatar Feb 08 '23 00:02 ZacSweers

It's not documented apparently, but if the only argument you pass is @file ktfmt takes what would normally be its command line arguments from file, one argument per line. So what would be

> ktfmt --google-style --dry-run some/dir/file1.kt some/other/dir/file2.kt build.gradle.kts ...

will do the same as

> cat args
--google-style
--dry-run
some/dir/file1.kt
some/other/dir/file2.kt
build.gradle.kts
...

> ktfmt @args

Introduced in this commit.

grodin avatar Mar 06 '23 16:03 grodin

It looks like this has been fixed. Can someone close the issue?

nreid260 avatar May 12 '23 05:05 nreid260