trunk_build_time/cmd/
config.rs

1use std::path::PathBuf;
2
3use anyhow::Result;
4use clap::{Args, Subcommand};
5
6use crate::config::ConfigOpts;
7
8/// Trunk config controls.
9#[derive(Clone, Debug, Args)]
10#[command(name = "config")]
11pub struct Config {
12    #[command(subcommand)]
13    action: ConfigSubcommands,
14}
15
16impl Config {
17    #[tracing::instrument(level = "trace", skip(self, config))]
18    pub async fn run(self, config: Option<PathBuf>) -> Result<()> {
19        // NOTE WELL: if we ever add additional subcommands, refactor this to match the pattern
20        // used in main, which is much more scalable. This is faster to code, and will not force
21        // incompatibility when new commands are added.
22        match self.action {
23            ConfigSubcommands::Show => {
24                let cfg = ConfigOpts::full(config)?;
25                println!("{:#?}", cfg);
26            }
27        }
28        Ok(())
29    }
30}
31
32#[derive(Clone, Debug, Subcommand)]
33enum ConfigSubcommands {
34    /// Show Trunk's current config pre-CLI.
35    Show,
36}