Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions espflash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,21 @@ fn main() -> Result<()> {
let mut opts = Opts::parse();
let config = Config::load()?;

// If neither the IMAGE nor SERIAL arguments have been provided, print the help
// message and exit.
if opts.image.is_none() && opts.connect_opts.serial.is_none() {
Opts::command().print_help().ok();
return Ok(());
}
if !matches!(opts.subcommand, Some(SubCommand::BoardInfo(..))) {
// If neither the IMAGE nor SERIAL arguments have been provided, print the
// help message and exit.
if opts.image.is_none() && opts.connect_opts.serial.is_none() {
Opts::command().print_help().ok();
return Ok(());
}

// If only a single argument is passed, it *should* always be the ELF file.
// In the case that the serial port was not provided as a command-line argument,
// we will either load the value specified in the configuration file or do port
// auto-detection instead.
if opts.image.is_none() && opts.connect_opts.serial.is_some() {
swap(&mut opts.image, &mut opts.connect_opts.serial);
// If only a single argument is passed, it *should* always be the ELF file. In
// the case that the serial port was not provided as a command-line argument, we
// will either load the value specified in the configuration file or do port
// auto-detection instead.
if opts.image.is_none() && opts.connect_opts.serial.is_some() {
swap(&mut opts.image, &mut opts.connect_opts.serial);
}
}

if let Some(subcommand) = opts.subcommand {
Expand Down