From 9a81a49c6ae1217928658dd1d6742868ec40931e Mon Sep 17 00:00:00 2001 From: Max Cohen Date: Sun, 25 Sep 2022 10:59:19 +0200 Subject: [PATCH] Add argument parser for the conduit executable Allow fetching the version with `conduit --version`. Fixes #285. --- src/clap.rs | 13 +++++++++++++ src/lib.rs | 1 + src/main.rs | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 src/clap.rs diff --git a/src/clap.rs b/src/clap.rs new file mode 100644 index 00000000..444f21bf --- /dev/null +++ b/src/clap.rs @@ -0,0 +1,13 @@ +//! Integration with `clap` + +use clap::Parser; + +/// Command line arguments +#[derive(Parser)] +#[clap(about, version)] +pub struct Args {} + +/// Parse command line arguments into structured data +pub fn parse() -> Args { + Args::parse() +} diff --git a/src/lib.rs b/src/lib.rs index 70c6f373..5a89f805 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ pub mod api; +pub mod clap; mod config; mod database; mod service; diff --git a/src/main.rs b/src/main.rs index 524f6886..e5861846 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,8 @@ static GLOBAL: Jemalloc = Jemalloc; #[tokio::main] async fn main() { + clap::parse(); + // Initialize config let raw_config = Figment::new()