Add support for the camel case mode, instead of regular mode.

This commit is contained in:
Oleksandr Kozachuk
2022-12-11 15:20:52 +01:00
parent 681ce3db23
commit ad920e8f05
3 changed files with 39 additions and 2 deletions
+15 -1
View File
@@ -48,10 +48,11 @@ peg::parser! {
_ => Err("unknown mode"),
}
}
rule rmode() -> Mode = m:$("R" / "r" / "U" / "u" / "N" / "n" / "H" / "h" / "B" / "b" / "D" / "d") {?
rule rmode() -> Mode = m:$("R" / "r" / "U" / "u" / "N" / "n" / "C" / "H" / "h" / "B" / "b" / "D" / "d") {?
match m.to_uppercase().as_str() {
"R" => Ok(Mode::Regular),
"N" => Ok(Mode::NoSpace),
"C" => Ok(Mode::NoSpaceCamel),
"U" => Ok(Mode::RegularUpcase),
"H" => Ok(Mode::Hex),
"B" => Ok(Mode::Base64),
@@ -233,6 +234,19 @@ mod tests {
comment: Some("a b c".to_string())
})
);
assert_eq!(
command_parser::name("ableton89 20C 98 2020-12-09 a b c"),
Ok(Password {
name: Rc::new("ableton89".to_string()),
parent: None,
prefix: None,
mode: Mode::NoSpaceCamel,
length: Some(20),
seq: 98,
date: NaiveDate::from_ymd_opt(2020, 12, 09).unwrap(),
comment: Some("a b c".to_string())
})
);
assert_eq!(
command_parser::name("ableton89 20D 2020-12-09 a b c"),
Ok(Password {