-
Notifications
You must be signed in to change notification settings - Fork 66
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 CLI alias for standard in #606
base: main
Are you sure you want to change the base?
Conversation
progenitor-impl/src/cli.rs
Outdated
use std::io::Read; | ||
let body_input = match value.as_str() { | ||
"-" => { | ||
let mut buf = Vec::new(); | ||
std::io::stdin().read_to_end(&mut buf).unwrap(); | ||
buf | ||
} | ||
file => std::fs::read(&file).unwrap() | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would from_reader
simplify this at all? https://docs.rs/serde_json/latest/serde_json/fn.from_reader.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, updated it to use from_reader
in both branches. Before merging though I would like to see if I can get a test in here. I don't think anything currently tests if a generated CLI would actually compile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be great
@augustuswm as I recall you were going to add a test; no rush, just wanted to make sure you weren't blocked on me. |
Correct, not blocked. On me to get that added. |
Added a rough pass at a compilation test. It is pretty much just a macro to generates tokens for each sdk and cli. These are then wrapped in tests that will fail to compile if the generated code fails to compile. The rest of the changes are largely bringing in the dev dependencies that the generated sdks and clis need to compile. There is probably a much more elegant way to construct these tests, but this is the first thing that came to mind. |
-
as an alias for standard in when specifying a json bodyThis mirrors how the
api
method of the oxide.rs CLI functions. Body handling now looks like (for some type T):