1#![feature(coverage_attribute)]
4
5pub mod cli;
6pub mod command;
7pub mod conventional_commit;
8pub(crate) mod env;
9pub mod filesystem;
10pub mod git;
11pub mod github;
12pub mod locale;
13pub mod model;
14pub mod package_manager;
15pub mod path;
16pub(crate) mod shell;
17pub mod tui;
18pub mod utils;
19
20#[cfg(any(test, feature = "test-support"))]
21pub mod test_logging;
22
23use std::process::ExitCode;
24
25pub use env::Env;
26
27pub async fn run(
33 cli: cli::Cli,
34 env: Env,
35 config: Option<model::config::Config>,
36) -> anyhow::Result<ExitCode> {
37 locale::set_locale(env.locale());
39
40 let dry_run = cli.global.dry_run;
41
42 match cli.command {
43 Some(cli::Command::Init(args)) => cli::cmd_init(&args, &cli.global, &env).await,
44 Some(cli::Command::Verify(args)) => cli::cmd_verify(&args, &env).await,
45 command => {
46 let config = config.ok_or_else(|| {
47 anyhow::anyhow!("No configuration found. Run 'cursus init' to create one.")
48 })?;
49 match command {
50 Some(cli::Command::Change(args)) => {
51 cli::cmd_change(&args, &cli.global, &env, config).await
52 }
53 Some(cli::Command::Prepare(args)) => {
54 cli::cmd_prepare(&args, dry_run, &env, config).await
55 }
56 Some(cli::Command::Publish(args)) => {
57 cli::cmd_publish(&args, dry_run, &env, config).await
58 }
59 Some(cli::Command::Ci(args)) => cli::cmd_ci(&args, dry_run, &env, config).await,
60 None => {
61 cli::cmd_change(&cli::ChangeArgs::default(), &cli.global, &env, config).await
62 }
63 Some(cli::Command::Init(_)) | Some(cli::Command::Verify(_)) => {
64 anyhow::bail!(
66 "Unexpected Init/Verify command in inner dispatch - this is a bug, please report it."
67 )
68 }
69 }
70 }
71 }
72}