Skip to content

Commit cd9f93f

Browse files
committed
feat: Move elf arg to MonitorConfigArgs
1 parent cd21e74 commit cd9f93f

File tree

4 files changed

+13
-28
lines changed

4 files changed

+13
-28
lines changed

cargo-espflash/src/main.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,9 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
363363
monitor_args.baud_rate = 74_880;
364364
}
365365

366-
monitor(
367-
flasher.into_serial(),
368-
Some(&elf_data),
369-
pid,
370-
monitor_args,
371-
Some(build_ctx.artifact_path),
372-
)
366+
monitor_args.elf = Some(build_ctx.artifact_path);
367+
368+
monitor(flasher.into_serial(), Some(&elf_data), pid, monitor_args)
373369
} else {
374370
Ok(())
375371
}

espflash/src/bin/espflash.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,9 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
298298
monitor_args.baud_rate = 74_880;
299299
}
300300

301-
monitor(
302-
flasher.into_serial(),
303-
Some(&elf_data),
304-
pid,
305-
monitor_args,
306-
Some(args.image),
307-
)
301+
monitor_args.elf = Some(args.image);
302+
303+
monitor(flasher.into_serial(), Some(&elf_data), pid, monitor_args)
308304
} else {
309305
Ok(())
310306
}

espflash/src/cli/mod.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,6 @@ pub struct MonitorArgs {
249249
/// Connection configuration
250250
#[clap(flatten)]
251251
connect_args: ConnectArgs,
252-
/// File name of the ELF image to load the symbols from
253-
#[arg(short = 'e', long, value_name = "FILE")]
254-
elf: Option<PathBuf>,
255252
/// Monitoring arguments
256253
#[clap(flatten)]
257254
monitor_args: MonitorConfigArgs,
@@ -264,6 +261,9 @@ pub struct MonitorConfigArgs {
264261
/// Baud rate at which to communicate with target device
265262
#[arg(short = 'r', long, env = "MONITOR_BAUD", default_value = "115_200", value_parser = parse_uint32)]
266263
pub baud_rate: u32,
264+
/// File name of the ELF image to load the symbols from
265+
#[arg(short = 'e', long, value_name = "FILE")]
266+
pub elf: Option<PathBuf>,
267267
/// Avoids asking the user for interactions like resetting the device
268268
#[arg(long)]
269269
non_interactive: bool,
@@ -432,7 +432,7 @@ pub fn serial_monitor(args: MonitorArgs, config: &Config) -> Result<()> {
432432
let mut flasher = connect(&args.connect_args, config, true, true)?;
433433
let pid = flasher.get_usb_pid()?;
434434

435-
let elf = if let Some(elf_path) = args.elf.clone() {
435+
let elf = if let Some(elf_path) = args.monitor_args.elf.clone() {
436436
let path = fs::canonicalize(elf_path).into_diagnostic()?;
437437
let data = fs::read(path).into_diagnostic()?;
438438

@@ -455,13 +455,7 @@ pub fn serial_monitor(args: MonitorArgs, config: &Config) -> Result<()> {
455455
monitor_args.baud_rate = 74_880;
456456
}
457457

458-
monitor(
459-
flasher.into_serial(),
460-
elf.as_deref(),
461-
pid,
462-
monitor_args,
463-
args.elf,
464-
)
458+
monitor(flasher.into_serial(), elf.as_deref(), pid, monitor_args)
465459
}
466460

467461
/// Convert the provided firmware image from ELF to binary

espflash/src/cli/monitor/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
use std::{
1414
io::{stdout, ErrorKind, Read, Write},
15-
path::PathBuf,
1615
time::Duration,
1716
};
1817

@@ -78,7 +77,6 @@ pub fn monitor(
7877
elf: Option<&[u8]>,
7978
pid: u16,
8079
monitor_args: MonitorConfigArgs,
81-
elf_file: Option<PathBuf>,
8280
) -> miette::Result<()> {
8381
if !monitor_args.non_interactive {
8482
println!("Commands:");
@@ -110,7 +108,8 @@ pub fn monitor(
110108
LogFormat::Serial => Box::new(parser::serial::Serial),
111109
};
112110

113-
let mut external_processors = ExternalProcessors::new(monitor_args.processors, elf_file)?;
111+
let mut external_processors =
112+
ExternalProcessors::new(monitor_args.processors, monitor_args.elf)?;
114113

115114
let mut buff = [0; 1024];
116115
loop {

0 commit comments

Comments
 (0)