Skip to content

Commit 3899d45

Browse files
Address review comments (#14426)
* Address review comments * Revert comments in `impl FromStr for ConfigValue`
1 parent b586ecf commit 3899d45

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

crates/tauri-cli/src/lib.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,24 @@ impl FromStr for ConfigValue {
6666
let raw =
6767
read_to_string(&path).fs_context("failed to read configuration file", path.clone())?;
6868

69-
// treat all other extensions as json
70-
// from tauri-utils/src/config/parse.rs:
71-
// we also want to support **valid** json5 in the .json extension
72-
// if the json5 is not valid the serde_json error for regular json will be returned.
7369
match path.extension().and_then(|ext| ext.to_str()) {
7470
Some("toml") => Ok(Self(::toml::from_str(&raw).with_context(|| {
7571
format!("failed to parse config at {} as TOML", path.display())
7672
})?)),
7773
Some("json5") => Ok(Self(::json5::from_str(&raw).with_context(|| {
7874
format!("failed to parse config at {} as JSON5", path.display())
7975
})?)),
80-
_ => Ok(Self(match ::json5::from_str(&raw) {
81-
Ok(json5) => json5,
82-
Err(_) => serde_json::from_str(&raw)
83-
.with_context(|| format!("failed to parse config at {} as JSON", path.display()))?,
84-
})),
76+
// treat all other extensions as json
77+
_ => Ok(Self(
78+
// from tauri-utils/src/config/parse.rs:
79+
// we also want to support **valid** json5 in the .json extension
80+
// if the json5 is not valid the serde_json error for regular json will be returned.
81+
match ::json5::from_str(&raw) {
82+
Ok(json5) => json5,
83+
Err(_) => serde_json::from_str(&raw)
84+
.with_context(|| format!("failed to parse config at {} as JSON", path.display()))?,
85+
},
86+
)),
8587
}
8688
}
8789
}
@@ -223,18 +225,20 @@ where
223225
Ok(s) => s,
224226
Err(e) => e.exit(),
225227
};
226-
228+
// set the verbosity level so subsequent CLI calls (xcode-script, android-studio-script) refer to it
227229
let verbosity_number = get_verbosity(cli.verbose);
228230
std::env::set_var("TAURI_CLI_VERBOSITY", verbosity_number.to_string());
229231

230232
let mut builder = Builder::from_default_env();
231233
if let Err(err) = builder
232234
.format_indent(Some(12))
233235
.filter(None, verbosity_level(verbosity_number).to_level_filter())
236+
// golbin spams an insane amount of really technical logs on the debug level so we're reducing one level
234237
.filter(
235238
Some("goblin"),
236239
verbosity_level(verbosity_number.saturating_sub(1)).to_level_filter(),
237240
)
241+
// handlebars is not that spammy but its debug logs are typically far from being helpful
238242
.filter(
239243
Some("handlebars"),
240244
verbosity_level(verbosity_number.saturating_sub(1)).to_level_filter(),
@@ -314,6 +318,8 @@ fn prettyprint_level(lvl: Level) -> &'static str {
314318
}
315319

316320
pub trait CommandExt {
321+
// The `pipe` function sets the stdout and stderr to properly
322+
// show the command output in the Node.js wrapper.
317323
fn piped(&mut self) -> std::io::Result<ExitStatus>;
318324
fn output_ok(&mut self) -> crate::Result<Output>;
319325
}

0 commit comments

Comments
 (0)