Improv device listing
This commit is contained in:
parent
197ba19520
commit
b28183fd53
@ -46,7 +46,7 @@ impl Default for DeviceCommands {
|
||||
#[command(arg_required_else_help = true)]
|
||||
enum Commands {
|
||||
/// List available serial devices
|
||||
ListDevices,
|
||||
List,
|
||||
/// Device
|
||||
Device {
|
||||
/// Path to the serial device
|
||||
@ -76,12 +76,13 @@ async fn main() -> Result<()>{
|
||||
let command = &cli.command.context("No command provided")?.clone();
|
||||
|
||||
match &command {
|
||||
Commands::ListDevices => {
|
||||
Commands::List => {
|
||||
println!("{}", tokio_serial::available_ports()
|
||||
.context("Failed to list available ports")?
|
||||
.iter()
|
||||
.map(|serialport| serialport.port_name.clone())
|
||||
.fold(String::new(), |a, b| a + &b + &String::from("\n")));
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n"));
|
||||
},
|
||||
Commands::Device {path, baud_rate, device_command} => {
|
||||
match &device_command.clone().unwrap_or_default() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user