From 9dc763583b904534fc550607f74a997c7d1ce9b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Damien?= Date: Thu, 23 Nov 2023 19:49:02 +0100 Subject: [PATCH] feat: Add cli flags to sort perpherals by name --- src/cli_args.rs | 4 ++++ src/main.rs | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cli_args.rs b/src/cli_args.rs index 744244e..7d4741d 100644 --- a/src/cli_args.rs +++ b/src/cli_args.rs @@ -109,4 +109,8 @@ pub struct Args { /// ``` #[clap(long, value_parser = clap::builder::ValueParser::new(parse_name_map))] pub names_map_file: Option>, + + /// Sort peripherals by name + #[clap(long)] + pub sort_by_name: bool, } diff --git a/src/main.rs b/src/main.rs index f4d7bf2..4f110e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,6 +37,7 @@ impl Ctx { #[tokio::main] async fn main() { let args = Args::parse(); + let sort_by_name = args.sort_by_name; let ctx = Arc::new(Ctx { args, latest_scan: RwLock::new(None), @@ -47,7 +48,7 @@ async fn main() { .expect("Can not establish BLE connection."), request_scan_restart: Mutex::new(false), global_error: Mutex::new(None), - sort_by_name: Mutex::new(false), + sort_by_name: Mutex::new(sort_by_name), }); let ctx_clone = Arc::clone(&ctx);