From 9be9937f75c2711d5d7fd9759ed615397fff5c7f Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 7 Jul 2025 18:37:01 +0200 Subject: Add --version option discover tool --- server/discover/Cargo.toml | 1 + server/discover/src/main.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) (limited to 'server/discover') diff --git a/server/discover/Cargo.toml b/server/discover/Cargo.toml index 6a1a8209..a9ffeff3 100644 --- a/server/discover/Cargo.toml +++ b/server/discover/Cargo.toml @@ -17,3 +17,4 @@ http-body-util = "0.1" hyper-util = { version = "0.1", features = ["full"] } hurrycurry-protocol = { path = "../protocol" } serde_json = "1.0.140" +clap = { version = "4.5.39", features = ["derive"] } diff --git a/server/discover/src/main.rs b/server/discover/src/main.rs index f546cd6c..0ed43927 100644 --- a/server/discover/src/main.rs +++ b/server/discover/src/main.rs @@ -17,6 +17,7 @@ */ #![feature(never_type)] use anyhow::Result; +use clap::Parser; use http_body_util::Full; use hurrycurry_protocol::registry::Entry; use hyper::{ @@ -29,7 +30,20 @@ use mdns_sd::{ServiceDaemon, ServiceEvent}; use std::{cmp::Reverse, collections::HashMap, net::SocketAddr, sync::Arc}; use tokio::{net::TcpListener, spawn, sync::RwLock}; +#[derive(Parser)] +struct Args { + /// Print version and exit + #[arg(short, long)] + version: bool, +} + fn main() -> Result<()> { + let args = Args::parse(); + if args.version { + println!("{}", env!("CARGO_PKG_VERSION")); + return Ok(()); + } + env_logger::init_from_env("LOG"); tokio::runtime::Builder::new_current_thread() .enable_all() -- cgit v1.2.3-70-g09d2