1use std::path::PathBuf;
2
3use xshell::Shell;
4
5use cli::r_cmd_check::RCmdCheckArg;
6
7mod cli;
8mod commands;
9mod extendrtests;
10
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12 let cli = cli::parse();
13 let shell = Shell::new()?;
14 let original_path = shell.current_dir();
15
16 let path: PathBuf = std::env::var("CARGO_MANIFEST_DIR")?.parse()?;
17
18 shell.change_dir(
19 path.parent()
20 .ok_or("Failed to get parent dir")?
21 .canonicalize()?,
22 );
23 match cli.command {
24 cli::Commands::Fmt => commands::cargo_fmt::run(&shell)?,
25 cli::Commands::CheckFmt => commands::cargo_fmt_check::run(&shell)?,
26 cli::Commands::RCmdCheck(RCmdCheckArg {
27 no_build_vignettes,
28 error_on,
29 check_dir,
30 }) => commands::r_cmd_check::run(
31 &shell,
32 no_build_vignettes,
33 error_on.into(),
34 check_dir,
35 original_path,
36 )?,
37 cli::Commands::Doc => commands::generate_docs::run(&shell)?,
38 cli::Commands::Msrv => commands::cargo_msrv::run(&shell)?,
39 cli::Commands::DevtoolsTest(args) => commands::devtools_test::run(&shell, args)?,
40 cli::Commands::Document => commands::rextendr_document::run(&shell)?,
41 };
42
43 Ok(())
44}