Skip to content

Commit 696375c

Browse files
committed
Remove the cli::clap module altogether
1 parent 25d709e commit 696375c

File tree

5 files changed

+31
-42
lines changed

5 files changed

+31
-42
lines changed

cargo-espflash/src/main.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ use cargo_metadata::Message;
99
use clap::{AppSettings, Parser};
1010
use espflash::{
1111
cli::{
12-
board_info,
13-
clap::{ConnectOpts, FlashOpts},
14-
connect, flash_elf_image,
15-
monitor::monitor,
16-
save_elf_as_image,
12+
board_info, connect, flash_elf_image, monitor::monitor, save_elf_as_image, ConnectOpts,
13+
FlashOpts,
1714
},
1815
Chip, Config, ImageFormatId,
1916
};
@@ -60,7 +57,6 @@ pub enum SubCommand {
6057
SaveImage(SaveImageOpts),
6158
}
6259

63-
/// Build the specified project/package using the provided options
6460
#[derive(Parser)]
6561
pub struct BuildOpts {
6662
/// Build the application using the release profile

espflash/src/cli/clap.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.

espflash/src/cli/mod.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,47 @@ use std::{
77
path::{Path, PathBuf},
88
};
99

10+
use clap::Parser;
1011
use config::Config;
1112
use miette::{IntoDiagnostic, Result, WrapErr};
1213
use serialport::{FlowControl, SerialPortType};
1314

14-
use self::clap::ConnectOpts;
1515
use crate::{
1616
cli::serial::get_serial_port_info, error::Error, Chip, FirmwareImage, Flasher, ImageFormatId,
1717
PartitionTable,
1818
};
1919

20-
pub mod clap;
2120
pub mod config;
2221
pub mod monitor;
2322

2423
mod line_endings;
2524
mod serial;
2625

26+
#[derive(Parser)]
27+
pub struct ConnectOpts {
28+
/// Serial port connected to target device
29+
pub serial: Option<String>,
30+
/// Baud rate at which to flash target device
31+
#[clap(long)]
32+
pub speed: Option<u32>,
33+
}
34+
35+
#[derive(Parser)]
36+
pub struct FlashOpts {
37+
/// Load the application to RAM instead of Flash
38+
#[clap(long)]
39+
pub ram: bool,
40+
/// Path to a binary (.bin) bootloader file
41+
#[clap(long)]
42+
pub bootloader: Option<PathBuf>,
43+
/// Path to a CSV file containing partition table
44+
#[clap(long)]
45+
pub partition_table: Option<PathBuf>,
46+
/// Open a serial monitor after flashing
47+
#[clap(long)]
48+
pub monitor: bool,
49+
}
50+
2751
pub fn connect(opts: &ConnectOpts, config: &Config) -> Result<Flasher> {
2852
let port_info = get_serial_port_info(opts, config)?;
2953

espflash/src/cli/serial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use dialoguer::{theme::ColorfulTheme, Confirm, Select};
33
use miette::{IntoDiagnostic, Result};
44
use serialport::{available_ports, SerialPortInfo, SerialPortType};
55

6-
use super::{clap::ConnectOpts, config::Config};
6+
use super::{config::Config, ConnectOpts};
77
use crate::{cli::config::UsbDevice, error::Error};
88

99
pub fn get_serial_port_info(

espflash/src/main.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ use std::{fs, mem::swap, path::PathBuf, str::FromStr};
33
use clap::{AppSettings, IntoApp, Parser};
44
use espflash::{
55
cli::{
6-
board_info,
7-
clap::{ConnectOpts, FlashOpts},
8-
connect, flash_elf_image,
9-
monitor::monitor,
10-
save_elf_as_image,
6+
board_info, connect, flash_elf_image, monitor::monitor, save_elf_as_image, ConnectOpts,
7+
FlashOpts,
118
},
129
Chip, Config, ImageFormatId,
1310
};

0 commit comments

Comments
 (0)