Implement typst eval --format=raw#8295
Conversation
| /// Output file format for eval command | ||
| #[derive(Debug, Default, Copy, Clone, Eq, PartialEq, ValueEnum)] | ||
| pub enum EvalSerializationFormat { | ||
| #[default] | ||
| Json, | ||
| Yaml, | ||
| Raw, | ||
| } | ||
|
|
||
| display_possible_values!(EvalSerializationFormat); | ||
|
|
There was a problem hiding this comment.
Unsure if duplicating SerializationFormat like this is the best design. I assume raw shouldn't be added as an option for query and info? In that case eval needs some separate type, and nesting SerializationFormat inside it doesn't work because it's not supported by ValueEnum.
There was a problem hiding this comment.
Should I separate the refactoring out to a separate commit? On the other hand, you seem to squash a lot anyway.
|
|
||
| let output = exec() | ||
| .arg("eval") | ||
| .arg("--format=raw") | ||
| .arg("bytes((1,2,3,0xff))") | ||
| .must_succeed(); | ||
| assert_eq!(output.stdout.0, b"\x01\x02\x03\xff"); |
There was a problem hiding this comment.
Did I miss any other tests for the CLI, or the ones in this file the only ones?
| EvalSerializationFormat::Json => { | ||
| println!("{}", crate::serialize(&value, SerializationFormat::Json, pretty)?); | ||
| } | ||
| EvalSerializationFormat::Yaml => { | ||
| println!("{}", crate::serialize(&value, SerializationFormat::Yaml, pretty)?); | ||
| } |
There was a problem hiding this comment.
Nesting SerializationFormat inside EvalSerializationFormat would be nice here of course, but probably not nice enough to justify hand-coding ValueEnum.
3832e2d to
32affe0
Compare
Fixes #7768.