1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use taplo_common::environment::Environment;
use crate::{
args::{TaploArgs, TaploCommand},
Taplo,
};
mod config;
mod format;
mod lint;
#[cfg(feature = "lsp")]
mod lsp;
mod queries;
#[cfg(feature = "toml-test")]
mod toml_test;
impl<E: Environment> Taplo<E> {
pub async fn execute(&mut self, taplo: TaploArgs) -> Result<(), anyhow::Error> {
self.colors = match taplo.colors {
crate::args::Colors::Auto => self.env.atty_stderr(),
crate::args::Colors::Always => true,
crate::args::Colors::Never => false,
};
match taplo.cmd {
TaploCommand::Format(fmt) => self.execute_format(fmt).await,
#[cfg(feature = "lsp")]
TaploCommand::Lsp { cmd } => self.execute_lsp(cmd).await,
#[cfg(feature = "toml-test")]
TaploCommand::TomlTest {} => self.execute_toml_test().await,
TaploCommand::Lint(cmd) => self.execute_lint(cmd).await,
TaploCommand::Config { cmd } => self.execute_config(cmd).await,
TaploCommand::Get(cmd) => self.execute_get(cmd).await,
}
}
}