Skip to main content

faucet_cli/commands/
list.rs

1//! `faucet list` — show every compiled-in source, sink, transform, and
2//! state-store backend so users can discover what their binary supports.
3
4use crate::error::CliResult;
5use crate::registry::{sink_descriptions, source_descriptions};
6use crate::state::available_state_kinds;
7#[cfg(feature = "quality")]
8use crate::transforms::quality_descriptions;
9use crate::transforms::transform_descriptions;
10
11/// Execute the `list` subcommand.
12pub async fn run() -> CliResult<()> {
13    println!("Sources:");
14    print_two_column(&source_descriptions());
15    println!();
16    println!("Sinks:");
17    print_two_column(&sink_descriptions());
18    println!();
19    println!("Transforms:");
20    print_two_column(&transform_descriptions());
21    println!();
22    #[cfg(feature = "quality")]
23    {
24        println!("Quality checks:");
25        print_two_column(&quality_descriptions());
26        println!();
27    }
28    println!("State stores: {}", available_state_kinds().join(", "));
29    #[cfg(feature = "schedule")]
30    println!("Scheduler:    compiled in (run `faucet schedule --help`, `faucet schema schedule`)");
31    Ok(())
32}
33
34fn print_two_column(entries: &[(&'static str, &'static str)]) {
35    if entries.is_empty() {
36        println!("  (none — rebuild faucet-cli with the relevant features enabled)");
37        return;
38    }
39    let width = entries.iter().map(|(n, _)| n.len()).max().unwrap_or(0);
40    for (name, desc) in entries {
41        println!("  {name:<width$}  {desc}", width = width);
42    }
43}