Show name, version and how to exit on repl
parent
da8d134cad
commit
6dc06f777d
|
@ -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"] }
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue