#![warn(missing_docs)]
#![forbid(unsafe_code)]
#![warn(clippy::perf)]
#![warn(clippy::pedantic)]
#![allow(clippy::module_name_repetitions)]
mod cli;
mod cmd;
mod error;
mod git;
mod model;
use std::io::stdout;
use clap::CommandFactory;
use clap_complete::generate;
use console::Term;
pub use self::cli::*;
pub use self::cmd::{
config as gitmoji_config, read_config_or_default, read_config_or_fail, write_config,
};
pub use self::error::*;
pub use self::model::*;
pub const EXIT_NO_CONFIG: i32 = 10;
pub const EXIT_CANNOT_UPDATE: i32 = 20;
pub async fn run(settings: Settings, term: &Term) -> Result<()> {
match settings.command {
Command::Init { default } => gitmoji_config(default, term).await,
Command::Commit { all, amend } => cmd::commit(all, amend, term).await,
Command::Update { url } => cmd::update_config(url).await,
Command::List => cmd::list().await,
Command::Search { text } => cmd::search(&text).await,
#[cfg(feature = "hook")]
Command::Hook(op) => match op {
HookOperation::Add => cmd::create_hook().await,
HookOperation::Remove => cmd::remove_hook().await,
HookOperation::Apply { dest, source } => cmd::apply_hook(dest, source, term).await,
},
Command::Completion { shell } => {
let mut cmd = <Settings as CommandFactory>::command();
generate(shell, &mut cmd, "gitmoji", &mut stdout());
Ok(())
}
}
}