rustic_rs/commands/
show_config.rs

1//! `show-config` subcommand
2
3use crate::{Application, RUSTIC_APP, status_err};
4
5use abscissa_core::{Command, Runnable, Shutdown};
6use anyhow::Result;
7use toml::to_string_pretty;
8
9/// `show-config` subcommand
10#[derive(clap::Parser, Command, Debug)]
11pub(crate) struct ShowConfigCmd {}
12
13impl Runnable for ShowConfigCmd {
14    fn run(&self) {
15        if let Err(err) = self.inner_run() {
16            status_err!("{}", err);
17            RUSTIC_APP.shutdown(Shutdown::Crash);
18        };
19    }
20}
21
22impl ShowConfigCmd {
23    fn inner_run(&self) -> Result<()> {
24        let config = to_string_pretty(RUSTIC_APP.config().as_ref())?;
25        println!("{config}");
26        Ok(())
27    }
28}