ktrs_cli/ktlint/mod.rs
1//! Port of the ktlint 2.0.0-ALPHA-4 CLI (`ktlint-cli`): the `ktlint` binary's flags, messages, reporters
2//! and exit codes, over ktrs-lint's engine and standard rules. Differential test: tools/ktlint-oracle/cli-diff.sh.
3//! With `--ktlint-version=1.8` (or `ktrs_ktlint_version = 1.8`) it is the 1.8.0 CLI instead: [`version`].
4//!
5//! A run that loads a rule set (`-R`) or reporter (`artifact=`) JAR with JVM code is handed to the real ktlint
6//! jar ([`ktlint_jar`]). Deviations: `--log-level=debug|trace` prints only the
7//! CLI's own messages, not the engine's; help text is wrapped for 80 columns whatever the terminal; a rule
8//! crash shows the panic, not a JVM stack trace.
9
10pub mod args;
11pub mod baseline;
12mod clikt;
13pub mod command_line;
14pub(crate) use ktrs_compose::jar as compose_jar;
15pub mod console;
16pub mod file_utils;
17pub mod gradle;
18mod hand_off_args;
19pub(crate) mod jar_providers;
20mod java_printf;
21pub mod java_glob;
22pub mod jpath;
23pub mod ktlint_jar;
24mod legacy_rule_set;
25pub mod logger;
26mod parallel;
27mod patterns;
28mod process;
29pub mod reporter;
30mod reporter_aggregator;
31mod run;
32pub(crate) use ktrs_compose::jar::sha256;
33mod subcommands;
34pub mod version;
35
36pub use command_line::{ExitCode, KtlintCli};
37
38/// The `ktlint` binary: `args` without the program name; returns the exit code.
39pub fn main(args: &[String]) -> i32 {
40 ktrs_lint::engine::silence_caught_rule_panics();
41 KtlintCli::from_env().run(args)
42}