Skip to content

Commit ef57036

Browse files
committed
Put all CLI dependencies and modules behind a feature
1 parent c128742 commit ef57036

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

espflash/Cargo.toml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,20 @@ pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ target }.{ archive
2828
bin-dir = "{ bin }{ binary-ext }"
2929
pkg-fmt = "zip"
3030

31+
[[bin]]
32+
name = "espflash"
33+
path = "./src/bin/espflash.rs"
34+
required-features = ["cli"]
35+
3136
[dependencies]
3237
base64 = "0.13.0"
3338
binread = "2.2.0"
3439
bytemuck = { version = "1.12.1", features = ["derive"] }
35-
clap = { version = "3.2.22", features = ["derive", "env"] }
40+
clap = { version = "3.2.22", features = ["derive", "env"], optional = true }
3641
comfy-table = "6.1.0"
37-
crossterm = "0.25.0"
42+
crossterm = { version = "0.25.0", optional = true }
3843
csv = "1.1.6"
39-
dialoguer = "0.10.2"
44+
dialoguer = { version = "0.10.2", optional = true }
4045
directories-next = "2.0.0"
4146
espmonitor = "0.10.0"
4247
env_logger = "0.9.0"
@@ -59,5 +64,9 @@ strum = "0.24.1"
5964
strum_macros = "0.24.3"
6065
thiserror = "1.0.35"
6166
toml = "0.5.9"
62-
update-informer = "0.5.0"
67+
update-informer = { version = "0.5.0", optional = true }
6368
xmas-elf = "0.8.0"
69+
70+
[features]
71+
default = ["cli"]
72+
cli = ["clap", "crossterm", "dialoguer", "update-informer"]

espflash/src/main.rs renamed to espflash/src/bin/espflash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn flash(mut args: FlashArgs, config: &Config) -> Result<()> {
123123
args.connect_args.use_stub = true;
124124
}
125125

126-
let mut flasher = connect(&args.connect_args, &config)?;
126+
let mut flasher = connect(&args.connect_args, config)?;
127127
flasher.board_info()?;
128128

129129
// Read the ELF data from the build path and load it to the target.
@@ -199,7 +199,7 @@ fn save_image(args: SaveImageArgs) -> Result<()> {
199199
}
200200

201201
fn write_bin(args: WriteBinArgs, config: &Config) -> Result<()> {
202-
let mut flasher = connect(&args.connect_args, &config)?;
202+
let mut flasher = connect(&args.connect_args, config)?;
203203
flasher.board_info()?;
204204

205205
let mut f = File::open(&args.bin_file).into_diagnostic()?;

espflash/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
#[cfg(feature = "cli")]
2+
pub use self::cli::config::Config;
13
pub use self::{
24
chip::Chip,
3-
cli::config::Config,
45
error::{Error, InvalidPartitionTable, MissingPartitionTable},
5-
flasher::{FlashFrequency, FlashMode},
6-
flasher::{FlashSize, Flasher},
6+
flasher::{FlashFrequency, FlashMode, FlashSize, Flasher},
77
image_format::ImageFormatId,
88
partition_table::PartitionTable,
99
};
1010

1111
pub mod chip;
12+
#[cfg(feature = "cli")]
1213
pub mod cli;
1314
pub mod command;
1415
pub mod connection;
@@ -30,6 +31,7 @@ pub mod logging {
3031
}
3132
}
3233

34+
#[cfg(feature = "cli")]
3335
pub mod update {
3436
use std::time::Duration;
3537

0 commit comments

Comments
 (0)