Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --argjson support #250

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add --argjson support #250

wants to merge 1 commit into from

Conversation

wader
Copy link
Contributor

@wader wader commented Dec 25, 2024

Fixes #180

@wader wader marked this pull request as draft December 25, 2024 18:48
let v = lexer
.exactly_one(Val::parse)
.map_err(|e| Error::Parse(format!("cannot parse {s} as JSON: {e}")));
Ok::<(std::string::String, Val), Error>((k.to_owned(), v?))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My rust knowledge fails me here, compiler not happy about deriving type parameter E for Result without this. Also looking at the other code i guess maybe you would like to refactor this to share parsing of json somehow?

let mut lexer = hifijson::SliceLexer::new(s.as_bytes());
let v = lexer
.exactly_one(Val::parse)
.map_err(|e| Error::Parse(format!("cannot parse {s} as JSON: {e}")));
Copy link
Contributor Author

@wader wader Dec 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably skip or truncate s and mention k in error message

"argjson" => {
let (name, value) = parse_key_val("--argjson", args)?;
self.argjson.push((name, value.into_string()?));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As i understand code i cli just collects stings, reading files, parsing etc should happen in binds?

@wader
Copy link
Contributor Author

wader commented Dec 25, 2024

And hope your having great holidays!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--argjson not supported
1 participant