changepacks_cli/commands/
config.rs

1use anyhow::Result;
2use changepacks_utils::get_changepacks_config;
3use clap::Args;
4
5#[derive(Args, Debug)]
6#[command(about = "Change changepacks configuration")]
7pub struct ConfigArgs {}
8
9/// Update project version
10pub async fn handle_config(_args: &ConfigArgs) -> Result<()> {
11    let current_dir = std::env::current_dir()?;
12    let config = get_changepacks_config(&current_dir).await?;
13    println!("{}", serde_json::to_string_pretty(&config)?);
14    Ok(())
15}
16
17#[cfg(test)]
18mod tests {
19    use super::*;
20    use clap::Parser;
21
22    #[derive(Parser)]
23    struct TestCli {
24        #[command(flatten)]
25        config: ConfigArgs,
26    }
27
28    #[test]
29    fn test_config_args_parsing() {
30        // ConfigArgs has no arguments, just verify it parses
31        let _cli = TestCli::parse_from(["test"]);
32    }
33
34    #[test]
35    fn test_config_args_debug() {
36        let args = ConfigArgs {};
37        let debug_str = format!("{:?}", args);
38        assert!(debug_str.contains("ConfigArgs"));
39    }
40}