ktstr/cli/
mod.rs

1//! CLI support functions shared between `ktstr` and `cargo-ktstr`.
2//!
3//! Validation, configuration, and kernel/KVM resolution logic used
4//! by both binaries.
5
6mod kernel_build;
7mod kernel_cmd;
8mod kernel_list;
9mod locks;
10mod parse;
11pub(crate) mod progress;
12mod resolve;
13mod stats_cmds;
14mod util;
15
16#[cfg(test)]
17mod testing;
18
19pub use kernel_cmd::{
20    CPU_CAP_HELP, DIRTY_TREE_CACHE_SKIP_HINT, EMBEDDED_KCONFIG, EOL_EXPLANATION,
21    EXTRA_KCONFIG_HELP, INCLUDE_EOL_HELP, KERNEL_HELP_BUILD, KERNEL_HELP_NO_RAW,
22    KERNEL_HELP_RAW_OK, KERNEL_LIST_LONG_ABOUT, KernelCommand, NON_GIT_TREE_CACHE_SKIP_HINT,
23    STALE_KCONFIG_EXPLANATION, UNTRACKED_KCONFIG_EXPLANATION, embedded_kconfig_hash,
24};
25
26pub use kernel_list::{format_entry_row, kernel_clean, kernel_list, kernel_list_range_preview};
27
28pub use kernel_build::{
29    KernelBuildResult, append_extra_kconfig_suffix, kernel_build_pipeline, make_kernel_with_output,
30    read_extra_kconfig, run_make, run_make_with_output, validate_kernel_config,
31};
32
33pub use parse::{DISK_HELP, parse_disk_arg, parse_disk_size_mib, parse_topology_string};
34
35pub use resolve::{
36    KernelDirCacheHit, KernelDirOutcome, KernelResolvePolicy, auto_download_kernel, cache_lookup,
37    check_kvm, check_tools, download_and_cache_version, expand_kernel_range, resolve_cached_kernel,
38    resolve_git_kernel, resolve_include_files, resolve_kernel_dir, resolve_kernel_dir_to_entry,
39    resolve_kernel_image, resolve_kernel_parallelism,
40};
41
42pub use stats_cmds::{
43    compare_partitions, compare_partitions_noise, explain_sidecar, list_metrics, list_runs,
44    list_values, print_stats_report, show_host, show_run_host, show_thresholds,
45};
46
47pub use locks::list_locks;
48
49pub use util::{
50    Spinner, new_table, new_wrapped_table, restore_sigpipe_default, stderr_color, stdout_color,
51};
52
53/// `FetchProgress` is the public handle the `ktstr` / `cargo-ktstr`
54/// binaries construct to render kernel-fetch progress (the parallel
55/// `resolve_kernel_set` and the single-shot `kernel build` paths).
56/// It must be `pub` (not `pub(crate)`) because those call sites live
57/// in the binary crates and thread `&FetchProgress` into the library
58/// resolvers — the same lib/bin-boundary reason [`Spinner`] is `pub`.
59/// The child-bar types (`GroupBar`, `CloneProgress`) stay
60/// `pub(crate)`: only the in-crate fetch path constructs them.
61pub use progress::FetchProgress;
62
63/// Re-export of the internal `vmm::host_topology::CpuCap` type so
64/// the `ktstr` and `cargo-ktstr` CLI binaries (which import this
65/// module through the `pub mod cli` surface) can resolve
66/// `--cpu-cap N` without depending on the `pub(crate)` `vmm`
67/// module. Keeping the canonical definition in `vmm::host_topology`
68/// (so the `acquire_llc_plan` internal call site consumes its own
69/// type without needing `cli`) and re-exporting here — versus
70/// inverting the dependency — avoids pulling the CLI module into
71/// the VMM internals.
72pub use crate::vmm::host_topology::CpuCap;
73
74/// Re-exports of the dimensional-slicing types used by
75/// `cargo-ktstr`'s `BuildCompareFilters::build()` plumbing. The
76/// `stats` module is `pub(crate)` (its tabular reporting types
77/// have no stable surface yet), but the `cargo-ktstr` binary needs
78/// `Dimension` and `derive_slicing_dims` to unit-test the
79/// filter-builder shape (the `BuildCompareFilters` tests assert
80/// which slicing dim a per-side filter pair derives). Same
81/// pattern as `CpuCap` above: keep the canonical definitions in
82/// `stats` (where the comparison plumbing consumes them
83/// internally) and re-export the slim slicing surface through
84/// `cli` so the binaries reach them through the public `cli`
85/// module.
86pub use crate::stats::{Dimension, derive_slicing_dims};
87
88/// Re-export of the comparison-policy types so downstream crates
89/// using `ktstr::cli` as their public surface don't need to reach
90/// into the internal `ktstr::stats` module (which is `pub(crate)` —
91/// see `lib.rs` — and therefore not a stable public path). The
92/// policy is the only item in `stats` that a CLI or external
93/// consumer constructs directly; every other item is internal
94/// plumbing reached via `cli::compare_partitions`.
95pub use crate::stats::{
96    AveragedGroup, ComparisonPolicy, GateOptions, PhaseDisplayOptions, RowFilter,
97    is_render_suppressed_component, metric_def,
98};