1
0
Fork 0

Show name, version and how to exit on repl

This commit is contained in:
Daniele Tricoli 2023-03-06 03:39:45 +01:00
parent da8d134cad
commit 6dc06f777d
2 changed files with 5 additions and 1 deletions

View File

@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
btleplug = "0.10.4"
clap = { version = "4.1.6", features = ["derive"] }
clap = { version = "4.1.6", features = ["derive", "cargo"] }
console = "0.15.5"
futures = "0.3.26"
indicatif = { version = "0.17.3", features = ["tokio"] }

View File

@ -7,6 +7,7 @@ use btleplug::api::{
BDAddr, Central, CentralEvent, Manager as _, Peripheral as _, ScanFilter, WriteType,
};
use btleplug::platform::{Adapter, Manager, Peripheral};
use clap::{crate_name, crate_version};
use console::Term;
use futures::stream::StreamExt;
use tokio::time;
@ -169,9 +170,12 @@ pub async fn send(
pub async fn repl(adapter_name: String, address: String) -> Result<(), Box<dyn Error>> {
let term = Term::stdout();
term.write_line(format!("{} {}", crate_name!(), crate_version!()).as_str())?;
term.write_line(format!("Connecting to... {}", address).as_str())?;
let device = find_device_by_address(adapter_name, address).await?;
device.connect().await?;
if device.is_connected().await? {
term.write_line("Connected. Type quit() to exit.")?;
device.discover_services().await?;
let line_channel = get_stdin_line_channel();