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(crate) use kernel_build::critical_config_options;
29pub use kernel_build::{
30    BuildReservation, KernelBuildResult, acquire_build_reservation,
31    acquire_build_reservation_waiting, acquire_build_reservation_waiting_interruptible,
32    acquire_build_reservation_waiting_interruptible_with_progress, append_extra_kconfig_suffix,
33    kernel_build_pipeline, make_kernel_with_output, read_extra_kconfig, run_make,
34    run_make_with_output, validate_kernel_config,
35};
36
37pub use parse::{DISK_HELP, parse_disk_arg, parse_disk_size_mib, parse_topology_string};
38
39pub use resolve::{
40    KernelDirCacheHit, KernelDirOutcome, KernelResolvePolicy, auto_download_kernel, cache_lookup,
41    check_kvm, check_tools, download_and_cache_version, expand_kernel_range, is_kernel_source_tree,
42    resolve_cached_kernel, resolve_git_kernel, resolve_include_files, resolve_kernel_dir,
43    resolve_kernel_dir_to_entry, resolve_kernel_image, resolve_kernel_parallelism,
44    shell_kernel_or_cwd,
45};
46
47pub use stats_cmds::{
48    compare_partitions, compare_partitions_noise, explain_sidecar, last_run_report, list_metrics,
49    list_runs, list_values, show_host, show_run_host, show_thresholds,
50};
51
52pub use locks::list_locks;
53
54pub use util::{
55    STATUS_LABEL_WIDTH, Spinner, new_bordered_table, new_table, new_wrapped_table,
56    print_status_line, restore_sigpipe_default, status_line, stderr_color, stderr_status_color,
57    stdout_color,
58};
59
60/// `FetchProgress` is the public handle the `ktstr` / `cargo-ktstr`
61/// binaries construct to render kernel-fetch progress (the parallel
62/// `resolve_kernel_set` and the single-shot `kernel build` paths).
63/// It must be `pub` (not `pub(crate)`) because those call sites live
64/// in the binary crates and thread `&FetchProgress` into the library
65/// resolvers — the same lib/bin-boundary reason [`Spinner`] is `pub`.
66/// The child-bar types (`GroupBar`, `CloneProgress`) stay
67/// `pub(crate)`: only the in-crate fetch path constructs them.
68pub use progress::FetchProgress;
69
70/// Re-export of the internal `vmm::host_topology::CpuCap` type so
71/// the `ktstr` and `cargo-ktstr` CLI binaries (which import this
72/// module through the `pub mod cli` surface) can resolve
73/// `--cpu-cap N` without depending on the `pub(crate)` `vmm`
74/// module. Keeping the canonical definition in `vmm::host_topology`
75/// (so the `acquire_llc_plan` internal call site consumes its own
76/// type without needing `cli`) and re-exporting here — versus
77/// inverting the dependency — avoids pulling the CLI module into
78/// the VMM internals.
79pub use crate::vmm::host_topology::CpuCap;
80
81/// Re-exports of the dimensional-slicing types used by
82/// `cargo-ktstr`'s `BuildCompareFilters::build()` plumbing. The
83/// `stats` module is `pub(crate)` (its tabular reporting types
84/// have no stable surface yet), but the `cargo-ktstr` binary needs
85/// `Dimension` and `derive_slicing_dims` to unit-test the
86/// filter-builder shape (the `BuildCompareFilters` tests assert
87/// which slicing dim a per-side filter pair derives). Same
88/// pattern as `CpuCap` above: keep the canonical definitions in
89/// `stats` (where the comparison plumbing consumes them
90/// internally) and re-export the slim slicing surface through
91/// `cli` so the binaries reach them through the public `cli`
92/// module.
93pub use crate::stats::{Dimension, derive_slicing_dims};
94
95/// Re-export of the comparison-policy types so downstream crates
96/// using `ktstr::cli` as their public surface don't need to reach
97/// into the internal `ktstr::stats` module (which is `pub(crate)` —
98/// see `lib.rs` — and therefore not a stable public path). The
99/// policy is the only item in `stats` that a CLI or external
100/// consumer constructs directly; every other item is internal
101/// plumbing reached via `cli::compare_partitions`.
102pub use crate::stats::{
103    AveragedGroup, ComparisonPolicy, GateOptions, PhaseDisplayOptions, RowFilter,
104    is_render_suppressed_component, metric_def,
105};