Skip to content

Commit bd1a0ec

Browse files
committed
Bump bitflags dependency, work around toml v1 breaking change
toml v1 breaks error handling. Catered for in Cargo.toml, but amend 2 demo scripts to maintain compatibility with current thag release.
1 parent e43c7c6 commit bd1a0ec

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ anyhow = { version = "1.0", optional = true }
233233
arboard = { version = "3.4", optional = true }
234234
atty = { version = "0.2", optional = true }
235235
backtrace = "0.3"
236-
bitflags = { version = "2.10", optional = true }
236+
bitflags = { version = "2", optional = true }
237237
cargo-lookup = { version = "0.1", optional = true }
238238
cargo_toml = { version = "0.22", optional = true }
239239
chrono = "0.4"

demo/config.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ simplelog = { version = "0.12", optional = true }
77
# - Git: Set THAG_GIT_REF=main to use git repository instead of crates.io
88
# Note: Run with 'thag script.rs' not 'cargo build' to enable thag-auto processing
99
thag_rs = { version = "0.2, thag-auto", default-features = false, features = ["config", "simplelog"] }
10-
toml = "0.9"
1110
1211
[features]
1312
default = ["simplelog"]
@@ -309,9 +308,9 @@ pub fn load(context: &dyn Context) -> ThagResult<Option<Config>> {
309308
eprintln!("config_path={config_path:?}");
310309

311310
if config_path.exists() {
312-
let config_str = fs::read_to_string(config_path)?;
311+
let config_str = fs::read_to_string(config_path).map_err(|e| e.to_string())?;
313312
debug_log!("config_str={config_str:?}");
314-
let config: Config = toml::from_str(&config_str)?;
313+
let config: Config = toml::from_str(&config_str).map_err(|e| e.to_string())å;
315314
debug_log!("config={config:?}");
316315
Ok(Some(config))
317316
} else {
@@ -370,7 +369,7 @@ fn main() -> ThagResult<()> {
370369
Ok(maybe_config) => {
371370
if let Some(config) = maybe_config {
372371
svprtln!(Role::EMPH, V::QQ, "Loaded config:");
373-
let toml = &toml::to_string_pretty(&config)?;
372+
let toml = &toml::to_string_pretty(&config).map_err(|e| e.to_string())?;
374373
for line in toml.lines() {
375374
svprtln!(Role::SUCC, V::QQ, "{line}");
376375
}

demo/config_with_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Config {
140140
// This function will bubble up any errors encountered.
141141
pub fn load(path: &Path) -> Result<Self, ThagError> {
142142
let content = std::fs::read_to_string(path)?;
143-
let config: Self = toml::from_str(&content)?;
143+
let config: Self = toml::from_str(&content).map_err(|e| e.to_string())?;
144144
config.validate()?;
145145
validate_config_format(&content)?;
146146
Ok(config)

0 commit comments

Comments
 (0)