Expand description
Port of the ktlint 2.0.0-ALPHA-4 CLI (ktlint-cli): the ktlint binary’s flags, messages, reporters
and exit codes, over ktrs-lint’s engine and standard rules. Differential test: tools/ktlint-oracle/cli-diff.sh.
With --ktlint-version=1.8 (or ktrs_ktlint_version = 1.8) it is the 1.8.0 CLI instead: version.
A run that loads a rule set (-R) or reporter (artifact=) JAR with JVM code is handed to the real ktlint
jar (ktlint_jar). Deviations: --log-level=debug|trace prints only the
CLI’s own messages, not the engine’s; help text is wrapped for 80 columns whatever the terminal; a rule
crash shows the panic, not a JVM stack trace.
Re-exports§
Modules§
- args
- The options of
KtlintCommandLineand its subcommands (Main.kt), parsed the way Clikt does. - baseline
- Port of
ktlint-cli-reporter-baseline’sBaseline.kt: loading a baseline of errors to ignore. - command_
line - Port of ktlint-cli
internal/KtlintCommandLine.kt(andMain.kt): thektlintcommand. - console
- The process streams the ktlint CLI writes to, swappable for in-process tests.
- file_
utils - Port of ktlint-cli
internal/FileUtils.kt: patterns (globs with gitignore-style!negation, files, directories) to the files to lint, walked in directory order from the patterns’ common parent. - gradle
- Hidden, ktrs-only options for the ktlint-gradle drop-in (
io.github.hexay.ktrs.ktlint, research/29). That plugin runs ktlint’s engine in-process with its own reporting; these options make a CLI run behave the same way: - java_
glob - Java’s
glob:PathMatcher(sun.nio.fs.Globs.toUnixRegexPattern), matched against a path string. - jpath
java.nio.file.Pathsemantics that ktlint’s file handling depends on, over/-separated strings (on Windows,\is read as/): parsing drops redundant separators,resolvekeeps./..,normalizeis lexical,startsWithcompares whole names.- ktlint_
jar - Runs the real ktlint release jar with the run’s argv when it loads a rule set JAR ktrs can’t run natively
(research/27-custom-rulesets-impl.md): stdout, stderr and exit code pass through untouched. The jar is the
release asset of the active
KtlintVersion, downloaded once into the user cache and checked against a pinned SHA-256;KTRS_KTLINT_JARoverrides the path (not checked). - logger
- ktlint’s logging: kotlin-logging over logback with its default
TTLLLayoutconsole appender, which writesHH:mm:ss.SSS [thread] LEVEL logger -- messageto stdout (also with--stdin). - reporter
- Ports of the built-in ktlint reporters (
ktlint-cli-reporter-*) and ofktlint-cli-reporter-core. A reporter is looked up by id (get_reporter), as ktlint’sReporterProviderV2service loader does. - version
- Which ktlint CLI the drop-in imitates:
--ktlint-version=<1.8|2.0>(ktrs only, hidden), elsektrs_ktlint_versionof the.editorconfigthat applies to the working directory, else 2.0. Chosen once per run and passed to the engine as an.editorconfigoverride, so every file follows it. The engine and rule switches: research/26-ktlint-18-mode.md.
Functions§
- main
- The
ktlintbinary:argswithout the program name; returns the exit code.