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.
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.
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.
|
@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
apimethod of the oxide.rs CLI functions. Body handling now looks like (for some type T):