1use std::env;
4
5use clap::Parser;
6use gitcc_core::Config;
7
8use crate::{info, new_line};
9
10#[derive(Debug, Parser)]
12pub struct ConfigArgs {
13 #[clap(long)]
15 pub yaml: bool,
16}
17
18pub fn run(args: ConfigArgs) -> anyhow::Result<()> {
20 new_line!();
21
22 let cwd = env::current_dir()?;
23 let config = Config::load_from_fs(&cwd)?;
24 let config = if let Some(c) = config {
25 c
26 } else {
27 info!("using default config");
28 Config::default()
29 };
30
31 new_line!();
32 let config_str = if args.yaml {
33 config.to_yaml()?
34 } else {
35 config.to_toml()?
36 };
37 println!("{}", config_str);
38
39 Ok(())
40}