Elide bundles google-java-format 1.32.0 and ktfmt 0.65. elide format runs both; elide javaformat and
elide ktfmt run one.
elide format -- src
elide javaformat -- Hello.java src/main/java
elide ktfmt -- Hello.kt src/main/kotlin
Files and directories go after -- and are rewritten in place. Each file is reported as unchanged, rewritten, would
be rewritten, or failed to parse. javaformat also accepts -i:
elide javaformat -- -i Hello.javaCheck formatting
-n or --dry-run after -- writes nothing and exits 1 if a file would change. --set-exit-if-changed is
accepted; there is no --check.
elide format -- -n src
elide javaformat -- -n src/main/java
elide ktfmt -- -n src/main/kotlinIn check mode, two Elide options (before --) report what would change:
elide format --list-files -- -n src
elide format --list-diffs -- -n src
elide format --list-diffs=5 -- -n src| Option | Output |
|---|---|
--list-files | Paths that would change, one per line on stdout. |
--list-diffs=N | Unified diffs when at most N files fail, otherwise paths. Use =N, not a separate value. |
Both work on javaformat and ktfmt too.
Formatter flags
Everything after -- is passed to the formatter, including argument files and style switches (--google-style,
--kotlinlang-style, --aosp):
elide ktfmt -- --google-style @kotlin-sources.txtelide javaformat --help and elide ktfmt --help show Elide’s options and how to show the formatter’s help.