Skip to content

Commit

Permalink
fix: add pattern for Glob
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeX4 committed Apr 24, 2024
1 parent 5608bc5 commit 866b34b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/mitex-parser/src/arg_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl ArgMatcherBuilder {
}
}
ArgPattern::Greedy => ArgMatcher::Greedy,
ArgPattern::Glob(re) => ArgMatcher::Glob {
ArgPattern::Glob { pattern: re } => ArgMatcher::Glob {
re: re.clone(),
prefix: String::new(),
},
Expand Down
5 changes: 4 additions & 1 deletion crates/mitex-spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ pub enum ArgPattern {
/// - {,b}: first, it matches a bracket option, e.g. `\sqrt[3]`
/// - t: it then matches a single term, e.g. `\sqrt[3]{a}` or `\sqrt{a}`
#[cfg_attr(feature = "serde", serde(rename = "glob"))]
Glob { pattern: GlobStr },
Glob {
/// The glob pattern to match the arguments
pattern: GlobStr,
},
}

// struct ArgShape(ArgPattern, Direction);
Expand Down
8 changes: 6 additions & 2 deletions crates/mitex-spec/src/preludes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ pub mod command {
pub fn define_glob_command(reg: &str, alias: &str) -> CommandSpecItem {
CommandSpecItem::Cmd(crate::CmdShape {
args: crate::ArgShape::Right {
pattern: crate::ArgPattern::Glob(reg.into()),
pattern: crate::ArgPattern::Glob {
pattern: reg.into(),
},
},
alias: Some(alias.to_owned()),
})
}

pub fn define_glob_env(reg: &str, alias: &str, ctx_feature: ContextFeature) -> CommandSpecItem {
CommandSpecItem::Env(crate::EnvShape {
args: crate::ArgPattern::Glob(reg.into()),
args: crate::ArgPattern::Glob {
pattern: reg.into(),
},
ctx_feature,
alias: Some(alias.to_owned()),
})
Expand Down

0 comments on commit 866b34b

Please sign in to comment.