mirror of
https://github.com/esp-rs/espflash.git
synced 2026-03-24 00:00:22 +00:00
Add modules containing helper functions for initializing the logger and checking for updates
This commit is contained in:
128
Cargo.lock
generated
128
Cargo.lock
generated
@@ -52,15 +52,6 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "array-init"
|
||||
version = "0.0.4"
|
||||
@@ -199,6 +190,7 @@ dependencies = [
|
||||
"cargo_metadata",
|
||||
"cargo_toml",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"espflash",
|
||||
"log",
|
||||
"miette",
|
||||
@@ -206,7 +198,6 @@ dependencies = [
|
||||
"strum",
|
||||
"thiserror",
|
||||
"toml",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -499,6 +490,19 @@ version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "espflash"
|
||||
version = "1.7.1-dev"
|
||||
@@ -512,6 +516,7 @@ dependencies = [
|
||||
"csv",
|
||||
"dialoguer",
|
||||
"directories-next",
|
||||
"env_logger",
|
||||
"espmonitor",
|
||||
"flate2",
|
||||
"indicatif",
|
||||
@@ -532,7 +537,6 @@ dependencies = [
|
||||
"strum_macros",
|
||||
"thiserror",
|
||||
"toml",
|
||||
"tracing-subscriber",
|
||||
"update-informer",
|
||||
"xmas-elf",
|
||||
]
|
||||
@@ -641,6 +645,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.3.0"
|
||||
@@ -792,15 +802,6 @@ version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||
dependencies = [
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maybe-uninit"
|
||||
version = "2.0.0"
|
||||
@@ -988,12 +989,6 @@ version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.25"
|
||||
@@ -1078,9 +1073,6 @@ name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
dependencies = [
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
@@ -1160,9 +1152,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.13"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711"
|
||||
checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1288,15 +1280,6 @@ dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.3.14"
|
||||
@@ -1503,15 +1486,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.6.0"
|
||||
@@ -1536,56 +1510,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"pin-project-lite",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"matchers",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"sharded-slab",
|
||||
"smallvec 1.9.0",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.15.0"
|
||||
@@ -1677,12 +1601,6 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
|
||||
@@ -33,11 +33,11 @@ pkg-fmt = "zip"
|
||||
cargo_metadata = "0.15.0"
|
||||
cargo_toml = "0.11.6"
|
||||
clap = { version = "3.2.22", features = ["derive", "env"] }
|
||||
env_logger = "0.9.0"
|
||||
espflash = { version = "=1.7.1-dev", path = "../espflash" }
|
||||
log = "0.4.17"
|
||||
miette = { version = "5.3.0", features = ["fancy"] }
|
||||
serde = { version = "1.0.144", features = ["derive"] }
|
||||
strum = "0.24.1"
|
||||
thiserror = "1.0.35"
|
||||
tracing-subscriber = { version = "0.3.15", features = [ "env-filter" ] }
|
||||
toml = "0.5.9"
|
||||
|
||||
@@ -39,6 +39,7 @@ csv = "1.1.6"
|
||||
dialoguer = "0.10.2"
|
||||
directories-next = "2.0.0"
|
||||
espmonitor = "0.10.0"
|
||||
env_logger = "0.9.0"
|
||||
flate2 = "1.0.24"
|
||||
indicatif = "0.17.1"
|
||||
log = "0.4.17"
|
||||
@@ -52,7 +53,6 @@ serde-hex = "0.1.0"
|
||||
serde_json = "1.0.85"
|
||||
serde_plain = "1.0.0"
|
||||
serialport = "4.2.0"
|
||||
tracing-subscriber = { version = "0.3.15", features = [ "env-filter" ] }
|
||||
sha2 = "0.10.6"
|
||||
slip-codec = "0.3.3"
|
||||
strum = "0.24.1"
|
||||
|
||||
@@ -418,13 +418,3 @@ pub fn write_bin_to_flash(opts: WriteBinToFlashOpts) -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn check_for_updates(name: &str, version: &str) {
|
||||
const NO_INTERVAL: Duration = Duration::from_secs(0);
|
||||
|
||||
let informer = update_informer::new(registry::Crates, name, version).interval(NO_INTERVAL);
|
||||
|
||||
if let Some(version) = informer.check_version().ok().flatten() {
|
||||
println!("New version of {name} is available: {version}\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
pub use chip::Chip;
|
||||
pub use cli::config::Config;
|
||||
pub use elf::{FlashFrequency, FlashMode};
|
||||
pub use error::{Error, InvalidPartitionTable, MissingPartitionTable};
|
||||
pub use flasher::{FlashSize, Flasher};
|
||||
pub use image_format::ImageFormatId;
|
||||
pub use partition_table::PartitionTable;
|
||||
pub use self::{
|
||||
chip::Chip,
|
||||
cli::config::Config,
|
||||
elf::{FlashFrequency, FlashMode},
|
||||
error::{Error, InvalidPartitionTable, MissingPartitionTable},
|
||||
flasher::{FlashSize, Flasher},
|
||||
image_format::ImageFormatId,
|
||||
partition_table::PartitionTable,
|
||||
};
|
||||
|
||||
pub mod chip;
|
||||
pub mod cli;
|
||||
pub mod command;
|
||||
pub mod connection;
|
||||
pub mod elf;
|
||||
@@ -16,8 +19,31 @@ pub mod flash_target;
|
||||
pub mod flasher;
|
||||
pub mod image_format;
|
||||
pub mod partition_table;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod cli;
|
||||
|
||||
pub mod stubs;
|
||||
|
||||
pub mod logging {
|
||||
use env_logger::Env;
|
||||
use log::LevelFilter;
|
||||
|
||||
pub fn initialize_logger(filter: LevelFilter) {
|
||||
env_logger::Builder::from_env(Env::default().default_filter_or(filter.as_str())).init();
|
||||
}
|
||||
}
|
||||
|
||||
pub mod update {
|
||||
use std::time::Duration;
|
||||
|
||||
use log::info;
|
||||
use update_informer::{registry, Check};
|
||||
|
||||
pub fn check_for_update(name: &str, version: &str) {
|
||||
// By setting the interval to 0 seconds we invalidate the cache with each
|
||||
// invocation and ensure we're getting up-to-date results
|
||||
let informer =
|
||||
update_informer::new(registry::Crates, name, version).interval(Duration::from_secs(0));
|
||||
|
||||
if let Some(version) = informer.check_version().ok().flatten() {
|
||||
info!("🚀 A new version of {name} is available: {version}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user