diff options
Diffstat (limited to 'crates/client/src/main.rs')
| -rw-r--r-- | crates/client/src/main.rs | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/crates/client/src/main.rs b/crates/client/src/main.rs new file mode 100644 index 00000000..45f09b1f --- /dev/null +++ b/crates/client/src/main.rs @@ -0,0 +1,79 @@ +#![forbid(unsafe_code)] +#![warn(clippy::pedantic, clippy::nursery, clippy::allow_attributes)] +#![expect( + clippy::missing_const_for_fn, // not 100% reliable + clippy::redundant_pub_crate, +)] + +use clap::Parser; +use clap::builder::Styles; +use clap::builder::styling::{AnsiColor, Effects}; +use eyre::Result; + +use command::AtuinCmd; +use tracing_subscriber::EnvFilter; + +mod command; + +pub(crate) mod atuin_client; +pub(crate) mod atuin_history; + +const VERSION: &str = env!("CARGO_PKG_VERSION"); +const SHA: &str = env!("GIT_HASH"); + +const LONG_VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", env!("GIT_HASH"), ")"); + +static HELP_TEMPLATE: &str = "\ +{before-help}{name} {version} +{author} +{about} + +{usage-heading} + {usage} + +{all-args}{after-help}"; + +const STYLES: Styles = Styles::styled() + .header(AnsiColor::Yellow.on_default().effects(Effects::BOLD)) + .usage(AnsiColor::Green.on_default().effects(Effects::BOLD)) + .literal(AnsiColor::Green.on_default().effects(Effects::BOLD)) + .placeholder(AnsiColor::Green.on_default()); + +/// Magical shell history +#[derive(Parser)] +#[command( + author = "Ellie Huxtable <ellie@atuin.sh>", + version = VERSION, + long_version = LONG_VERSION, + help_template(HELP_TEMPLATE), + styles = STYLES, +)] +struct Atuin { + #[command(subcommand)] + atuin: AtuinCmd, +} + +impl Atuin { + fn run(self) -> Result<()> { + self.atuin.run() + } +} + +fn main() -> Result<()> { + if let Err(e) = tracing_subscriber::fmt() + .with_file(true) + .with_line_number(true) + .with_level(true) + .without_time() + .with_env_filter( + EnvFilter::builder() + .from_env_lossy() + .add_directive("turtle=debug".parse().unwrap()), + ) + .try_init() + { + eprintln!("failed to initialize logging: {e}"); + } + + Atuin::parse().run() +} |
