Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
schpet committed Sep 24, 2024
1 parent 02379dd commit 1aa064d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn parse_args(vars: &[String]) -> Result<HashMap<String, String>, String> {
vars.iter().try_fold(HashMap::new(), |mut acc, arg| {
let parts: Vec<&str> = arg.splitn(2, '=').collect();
if parts.len() == 2 {
let key = parser::key_parser
let key = parser::key_parser()
.parse(parts[0])
.map_err(|_| format!("Invalid key format in argument: {}", arg.bold().red()))?;
acc.insert(key, parts[1].to_string());
Expand Down
11 changes: 5 additions & 6 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ pub enum Line {
},
}

// Parser for keys
pub fn key_parser() -> impl Parser<char, String, Error = Simple<char>> + Clone {
text::ident().padded()
}

pub fn parser() -> impl Parser<char, Vec<Line>, Error = Simple<char>> + Clone {
// Parser for comments
let comment = just('#')
.ignore_then(take_until(text::newline().or(end())))
.map(|(chars, _)| chars.into_iter().collect::<String>())
.map(Line::Comment);

// Parser for keys
pub fn key_parser() -> impl Parser<char, String, Error = Simple<char>> + Clone {
text::ident().padded()
}

pub use key_parser;

let key = key_parser();

Expand Down

0 comments on commit 1aa064d

Please sign in to comment.