Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Merge #126
Browse files Browse the repository at this point in the history
126: Print probe list when multiple probes were found r=jonas-schievink a=hasheddan

Prints all discovered probes when error is multiple probes found. Adapts
print_probes to accept a Vec such that it does not list probes after
they were already listed previously.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>

Fixes #118 

Co-authored-by: hasheddan <georgedanielmangum@gmail.com>
  • Loading branch information
bors[bot] and hasheddan authored Dec 21, 2020
2 parents b3d3538 + a9932d8 commit 7d1b420
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn notmain() -> Result<i32, anyhow::Error> {
logger::init(opts.verbose);

if opts.list_probes {
return print_probes();
return print_probes(Probe::list_all());
}

if opts.list_chips {
Expand Down Expand Up @@ -301,6 +301,7 @@ fn notmain() -> Result<i32, anyhow::Error> {
}
log::debug!("found {} probes", probes.len());
if probes.len() > 1 {
let _ = print_probes(probes);
bail!("more than one probe found; use --probe to specify which one to use");
}
let mut probe = probes[0].open()?;
Expand Down Expand Up @@ -852,9 +853,7 @@ fn probes_filter(probes: &[DebugProbeInfo], selector: &DebugProbeSelector) -> Ve
.collect()
}

fn print_probes() -> Result<i32, anyhow::Error> {
let probes = Probe::list_all();

fn print_probes(probes: Vec<DebugProbeInfo>) -> Result<i32, anyhow::Error> {
if !probes.is_empty() {
println!("The following devices were found:");
probes
Expand Down

0 comments on commit 7d1b420

Please sign in to comment.