From ad0c1a69cba1deaaa93a89d6f0723a0be9fe0579 Mon Sep 17 00:00:00 2001 From: Joscha Date: Mon, 7 Aug 2023 14:18:01 +0200 Subject: [PATCH] Move command line args to new file --- src/args.rs | 19 +++++++++++++++++++ src/main.rs | 24 +++++------------------- 2 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 src/args.rs diff --git a/src/args.rs b/src/args.rs new file mode 100644 index 0000000..ebeefd4 --- /dev/null +++ b/src/args.rs @@ -0,0 +1,19 @@ +use std::path::PathBuf; + +pub const NAME: &str = env!("CARGO_PKG_NAME"); +pub const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", env!("VERGEN_GIT_SHA"), ")"); + +#[derive(Debug, clap::Parser)] +#[command(name = NAME, version = VERSION)] +pub struct Args { + /// Path to the repo's tablejohn database. + pub db: PathBuf, + /// Path to the git repo. + pub repo: PathBuf, + /// Path to the config file. + #[arg(long, short)] + pub config: Option, + /// Enable increasingly more verbose output + #[arg(long, short, action = clap::ArgAction::Count)] + pub verbose: u8, +} diff --git a/src/main.rs b/src/main.rs index 29c0467..2cb1108 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +mod args; mod config; mod recurring; mod somehow; @@ -16,25 +17,10 @@ use tracing_subscriber::{ filter::Targets, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, }; -use crate::config::Config; - -const NAME: &str = env!("CARGO_PKG_NAME"); -const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", env!("VERGEN_GIT_SHA"), ")"); - -#[derive(Debug, clap::Parser)] -#[command(name = NAME, version = VERSION)] -struct Args { - /// Path to the repo's tablejohn database. - db: PathBuf, - /// Path to the git repo. - repo: PathBuf, - /// Path to the config file. - #[arg(long, short)] - config: Option, - /// Enable increasingly more verbose output - #[arg(long, short, action = clap::ArgAction::Count)] - verbose: u8, -} +use crate::{ + args::{Args, NAME, VERSION}, + config::Config, +}; fn set_up_logging(verbose: u8) { let filter = Targets::new()