taplo_cli/commands/
config.rs1use schemars::schema_for;
2use taplo_common::{config::Config, environment::Environment};
3use tokio::io::AsyncWriteExt;
4
5use crate::{args::ConfigCommand, default_config, Taplo};
6
7impl<E: Environment> Taplo<E> {
8 pub async fn execute_config(&self, cmd: ConfigCommand) -> Result<(), anyhow::Error> {
9 let mut stdout = self.env.stdout();
10 match cmd {
11 ConfigCommand::Default => {
12 stdout
13 .write_all(toml::to_string_pretty(&default_config())?.as_bytes())
14 .await?;
15 stdout.flush().await?;
16 Ok(())
17 }
18 ConfigCommand::Schema => {
19 stdout
20 .write_all(serde_json::to_string_pretty(&schema_for!(Config))?.as_bytes())
21 .await?;
22 stdout.flush().await?;
23 Ok(())
24 }
25 }
26 }
27}