Skip to main content

xtask_lib/tasks/
install_importer.rs

1//! `cargo xtask install-importer` — install the Cadmus importer crate.
2//!
3//! Runs `cargo install --path crates/importer`.  Any extra arguments are
4//! forwarded to `cargo install`.  Native dependencies are built automatically
5//! by `build.rs`.
6
7use anyhow::Result;
8use clap::Args;
9
10use super::util::{cmd, workspace};
11
12/// Arguments for `cargo xtask install-importer`.
13#[derive(Debug, Args)]
14pub struct InstallImporterArgs {
15    /// Extra arguments forwarded to `cargo install --path crates/importer`.
16    #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
17    pub extra: Vec<String>,
18}
19
20/// Installs the importer crate.
21pub fn run(args: InstallImporterArgs) -> Result<()> {
22    let root = workspace::root()?;
23
24    let importer_path = root.join("crates/importer");
25    let importer_str = importer_path.to_string_lossy().into_owned();
26
27    let mut cargo_args = vec!["install", "--path", &importer_str];
28    let extra_refs: Vec<&str> = args.extra.iter().map(String::as_str).collect();
29    cargo_args.extend_from_slice(&extra_refs);
30
31    cmd::run("cargo", &cargo_args, &root, &[])
32}