style: format the whole tree with cargo fmt (stock defaults, #35)
One-time, mechanical reformat — no functional changes. The tree was not rustfmt-clean (~1800 hunks across ~100 files); this brings it to stock `cargo fmt` defaults so a `cargo fmt --check` CI gate can follow. Behaviour-preserving: 2509 pass / 0 fail / 1 ignored (unchanged baseline), clippy clean. A .git-blame-ignore-revs entry follows so `git blame` skips this commit.
This commit is contained in:
+44
-24
@@ -96,10 +96,7 @@ pub enum ArgsError {
|
||||
impl std::fmt::Display for ArgsError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::MissingValue(flag) => f.write_str(&crate::t!(
|
||||
"cli.missing_value",
|
||||
flag = flag,
|
||||
)),
|
||||
Self::MissingValue(flag) => f.write_str(&crate::t!("cli.missing_value", flag = flag,)),
|
||||
Self::InvalidValue {
|
||||
flag,
|
||||
value,
|
||||
@@ -110,10 +107,7 @@ impl std::fmt::Display for ArgsError {
|
||||
value = value,
|
||||
expected = expected,
|
||||
)),
|
||||
Self::Unknown(arg) => f.write_str(&crate::t!(
|
||||
"cli.unknown_argument",
|
||||
arg = arg,
|
||||
)),
|
||||
Self::Unknown(arg) => f.write_str(&crate::t!("cli.unknown_argument", arg = arg,)),
|
||||
Self::MultiplePaths { first, second } => f.write_str(&crate::t!(
|
||||
"cli.multiple_paths",
|
||||
first = first,
|
||||
@@ -261,7 +255,11 @@ fn default_theme() -> Theme {
|
||||
// Standard convention: 0..=6 and 8 are dark backgrounds,
|
||||
// 7 and 9..=15 are light. ITerm emits 15 for white-ish.
|
||||
let is_dark = matches!(code, 0..=6 | 8);
|
||||
return if is_dark { Theme::dark() } else { Theme::light() };
|
||||
return if is_dark {
|
||||
Theme::dark()
|
||||
} else {
|
||||
Theme::light()
|
||||
};
|
||||
}
|
||||
Theme::default()
|
||||
}
|
||||
@@ -314,10 +312,19 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn mode_flag_simple_and_advanced() {
|
||||
assert_eq!(Args::parse(["--mode", "simple"]).unwrap().mode, Some(Mode::Simple));
|
||||
assert_eq!(Args::parse(["--mode", "advanced"]).unwrap().mode, Some(Mode::Advanced));
|
||||
assert_eq!(
|
||||
Args::parse(["--mode", "simple"]).unwrap().mode,
|
||||
Some(Mode::Simple)
|
||||
);
|
||||
assert_eq!(
|
||||
Args::parse(["--mode", "advanced"]).unwrap().mode,
|
||||
Some(Mode::Advanced)
|
||||
);
|
||||
// Case-insensitive, like the `mode` command.
|
||||
assert_eq!(Args::parse(["--mode", "ADVANCED"]).unwrap().mode, Some(Mode::Advanced));
|
||||
assert_eq!(
|
||||
Args::parse(["--mode", "ADVANCED"]).unwrap().mode,
|
||||
Some(Mode::Advanced)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -350,7 +357,10 @@ mod tests {
|
||||
#[test]
|
||||
fn data_dir_flag_parses() {
|
||||
let args = Args::parse(["--data-dir", "/tmp/playground-data"]).unwrap();
|
||||
assert_eq!(args.data_dir.as_deref(), Some(std::path::Path::new("/tmp/playground-data")));
|
||||
assert_eq!(
|
||||
args.data_dir.as_deref(),
|
||||
Some(std::path::Path::new("/tmp/playground-data"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -370,13 +380,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn data_dir_and_positional_can_coexist() {
|
||||
let args = Args::parse([
|
||||
"--data-dir",
|
||||
"/tmp/data",
|
||||
"/home/me/MyProject",
|
||||
])
|
||||
.unwrap();
|
||||
assert_eq!(args.data_dir.as_deref(), Some(std::path::Path::new("/tmp/data")));
|
||||
let args = Args::parse(["--data-dir", "/tmp/data", "/home/me/MyProject"]).unwrap();
|
||||
assert_eq!(
|
||||
args.data_dir.as_deref(),
|
||||
Some(std::path::Path::new("/tmp/data"))
|
||||
);
|
||||
assert_eq!(
|
||||
args.project_path.as_deref(),
|
||||
Some(std::path::Path::new("/home/me/MyProject"))
|
||||
@@ -386,7 +394,10 @@ mod tests {
|
||||
#[test]
|
||||
fn two_positional_paths_error() {
|
||||
let err = Args::parse(["/a", "/b"]).unwrap_err();
|
||||
assert!(matches!(err, ArgsError::MultiplePaths { .. }), "got: {err:?}");
|
||||
assert!(
|
||||
matches!(err, ArgsError::MultiplePaths { .. }),
|
||||
"got: {err:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -455,7 +466,10 @@ mod tests {
|
||||
// Absent `--demo` (and absent env var in the test runner),
|
||||
// demo mode is off — zero footprint for real users.
|
||||
let args = Args::parse(std::iter::empty::<&str>()).unwrap();
|
||||
assert!(!args.demo, "demo is off unless --demo or the env var is given");
|
||||
assert!(
|
||||
!args.demo,
|
||||
"demo is off unless --demo or the env var is given"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -484,7 +498,10 @@ mod tests {
|
||||
}
|
||||
// Disabling values.
|
||||
for v in ["", " ", "0", "false", "False", "no", "off", "OFF"] {
|
||||
assert!(!demo_value_is_truthy(v), "{v:?} should not enable demo mode");
|
||||
assert!(
|
||||
!demo_value_is_truthy(v),
|
||||
"{v:?} should not enable demo mode"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,7 +510,10 @@ mod tests {
|
||||
// Make sure the path-vs-flag distinction is robust:
|
||||
// unknown flags don't get silently swallowed as paths.
|
||||
let err = Args::parse(["--bogus", "/some/path"]).unwrap_err();
|
||||
assert!(matches!(&err, ArgsError::Unknown(s) if s == "--bogus"), "got: {err:?}");
|
||||
assert!(
|
||||
matches!(&err, ArgsError::Unknown(s) if s == "--bogus"),
|
||||
"got: {err:?}"
|
||||
);
|
||||
}
|
||||
|
||||
// ---- ADR-0054: --version / -V ----
|
||||
|
||||
Reference in New Issue
Block a user