idt/installers/
taplo.rs

1use std::path::Path;
2
3use crate::Installer;
4
5pub struct Taplo<'a> {
6    pub bin_dir: &'a Path,
7}
8
9impl Installer for Taplo<'_> {
10    fn bin_name(&self) -> &'static str {
11        "taplo"
12    }
13
14    fn install(&self) -> color_eyre::Result<()> {
15        // Installing with `cargo` because of:
16        // 1. no particular requirements
17        // 2. https://github.com/tamasfe/taplo/issues/542
18        ytil_cmd::silent_cmd("cargo")
19            .args([
20                "install",
21                &format!("{}-cli", self.bin_name()),
22                "--force",
23                "--all-features",
24                "--root",
25                // `--root` automatically append `bin` 🥲
26                self.bin_dir.to_string_lossy().trim_end_matches("bin"),
27            ])
28            .status()?;
29
30        ytil_sys::file::chmod_x(self.bin_dir.join(self.bin_name()))?;
31
32        Ok(())
33    }
34}