Command - Cleanup names (#3430)

This commit is contained in:
PabstMirror
2024-10-07 17:39:48 -05:00
committed by GitHub
parent 464605c725
commit 8658d0e773

View File

@@ -216,7 +216,7 @@ impl Command {
})
.collect::<Vec<_>>();
let mut command = Self::default();
command.set_name(name.to_string());
command.set_name(Self::get_cmd_name(name).to_string());
let mut lines = lines.into_iter().peekable();
let mut syntax_counter = 1;
@@ -327,4 +327,28 @@ impl Command {
}
Ok((command, errors))
}
fn get_cmd_name(name: &str) -> &str {
match name {
"!_a" => "!",
"%2B" => "+",
"a_*_b" => "*",
"a_/_b" => "/",
"a_:_b" => ":",
"a_%3D%3D_b" => "==",
"a_!%3D_b" => "!=",
"a_%3D_b" => "=",
"a_%5E_b" => "^",
"a_%25_b" => "%",
"a_%26%26_b" => "&&",
"a_greater%3D_b" => ">=",
"a_greater_b" => ">",
"a_hash_b" => "#",
"a_less%3D_b" => "<=",
"a_less_b" => "<",
"a_or_b" => "||",
"config_greater_greater_name" => ">>",
_ => name,
}
}
}