xtask/
main.rs

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
38
39
40
41
42
43
44
use std::path::PathBuf;

use xshell::Shell;

use cli::r_cmd_check::RCmdCheckArg;

mod cli;
mod commands;
mod extendrtests;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let cli = cli::parse();
    let shell = Shell::new()?;
    let original_path = shell.current_dir();

    let path: PathBuf = std::env::var("CARGO_MANIFEST_DIR")?.parse()?;

    shell.change_dir(
        path.parent()
            .ok_or("Failed to get parent dir")?
            .canonicalize()?,
    );
    match cli.command {
        cli::Commands::Fmt => commands::cargo_fmt::run(&shell)?,
        cli::Commands::CheckFmt => commands::cargo_fmt_check::run(&shell)?,
        cli::Commands::RCmdCheck(RCmdCheckArg {
            no_build_vignettes,
            error_on,
            check_dir,
        }) => commands::r_cmd_check::run(
            &shell,
            no_build_vignettes,
            error_on.into(),
            check_dir,
            original_path,
        )?,
        cli::Commands::Doc => commands::generate_docs::run(&shell)?,
        cli::Commands::Msrv => commands::cargo_msrv::run(&shell)?,
        cli::Commands::DevtoolsTest(args) => commands::devtools_test::run(&shell, args)?,
        cli::Commands::Document => commands::rextendr_document::run(&shell)?,
    };

    Ok(())
}