fix(src): Rename `TrinitryInvokation` to just `Trinitry` for simplicity

This commit is contained in:
Benedikt Peetz 2024-05-18 19:57:30 +02:00
parent 7dd5da97f6
commit d9ceb571d2
Signed by: bpeetz
GPG Key ID: B6139BCB07CE946D
1 changed files with 11 additions and 11 deletions

View File

@ -81,12 +81,12 @@ use pest::error::Error;
mod parsing; mod parsing;
pub struct TrinitryInvokation { pub struct Trinitry {
command: String, command: String,
arguments: Vec<String>, arguments: Vec<String>,
} }
impl TrinitryInvokation { impl Trinitry {
pub fn new(input: &str) -> Result<Self, <Self as FromStr>::Err> { pub fn new(input: &str) -> Result<Self, <Self as FromStr>::Err> {
input.parse() input.parse()
} }
@ -100,7 +100,7 @@ impl TrinitryInvokation {
} }
} }
impl FromStr for TrinitryInvokation { impl FromStr for Trinitry {
type Err = Error<Rule>; type Err = Error<Rule>;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
@ -109,7 +109,7 @@ impl FromStr for TrinitryInvokation {
} }
} }
impl From<TrinitryParser<'_>> for TrinitryInvokation { impl From<TrinitryParser<'_>> for Trinitry {
fn from(parsed: TrinitryParser) -> Self { fn from(parsed: TrinitryParser) -> Self {
let command = { let command = {
let command: Vec<_> = parsed.0.clone().find_tagged("command").collect(); let command: Vec<_> = parsed.0.clone().find_tagged("command").collect();
@ -161,7 +161,7 @@ impl From<TrinitryParser<'_>> for TrinitryInvokation {
} }
} }
impl Display for TrinitryInvokation { impl Display for Trinitry {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.arguments.is_empty() { if self.arguments.is_empty() {
f.write_str(&self.command) f.write_str(&self.command)
@ -179,12 +179,12 @@ mod tests;
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::TrinitryInvokation; use crate::Trinitry;
#[test] #[test]
fn parse_cmd() { fn parse_cmd() {
let string = "quit"; let string = "quit";
let p = TrinitryInvokation::new(string).unwrap_or_else(|e| { let p = Trinitry::new(string).unwrap_or_else(|e| {
panic!("{}", e); panic!("{}", e);
}); });
assert_eq!(&p.command, "quit"); assert_eq!(&p.command, "quit");
@ -194,7 +194,7 @@ mod test {
#[test] #[test]
fn parse_arg_clean() { fn parse_arg_clean() {
let string = r##"lua print("Hi")"##; let string = r##"lua print("Hi")"##;
let p = TrinitryInvokation::new(string).unwrap_or_else(|e| { let p = Trinitry::new(string).unwrap_or_else(|e| {
panic!("{}", e); panic!("{}", e);
}); });
assert_eq!(&p.command, "lua"); assert_eq!(&p.command, "lua");
@ -204,7 +204,7 @@ mod test {
#[test] #[test]
fn parse_arg_quote() { fn parse_arg_quote() {
let string = r##"write "some 'file' name""##; let string = r##"write "some 'file' name""##;
let p = TrinitryInvokation::new(string).unwrap_or_else(|e| { let p = Trinitry::new(string).unwrap_or_else(|e| {
panic!("{}", e); panic!("{}", e);
}); });
assert_eq!(&p.command, "write"); assert_eq!(&p.command, "write");
@ -214,7 +214,7 @@ mod test {
#[test] #[test]
fn parse_arg_single_quote() { fn parse_arg_single_quote() {
let string = r##"write 'some "file" name'"##; let string = r##"write 'some "file" name'"##;
let p = TrinitryInvokation::new(string).unwrap_or_else(|e| { let p = Trinitry::new(string).unwrap_or_else(|e| {
panic!("{}", e); panic!("{}", e);
}); });
assert_eq!(&p.command, "write"); assert_eq!(&p.command, "write");
@ -224,7 +224,7 @@ mod test {
#[test] #[test]
fn parse_arg_multi() { fn parse_arg_multi() {
let string = r##"write 'some "file" name' "other name" last"##; let string = r##"write 'some "file" name' "other name" last"##;
let p = TrinitryInvokation::new(string).unwrap_or_else(|e| { let p = Trinitry::new(string).unwrap_or_else(|e| {
panic!("{}", e); panic!("{}", e);
}); });