Skip to content

Implement typst eval --format=raw#8295

Open
Xiretza wants to merge 1 commit into
typst:mainfrom
Xiretza:typst-eval-raw-out
Open

Implement typst eval --format=raw#8295
Xiretza wants to merge 1 commit into
typst:mainfrom
Xiretza:typst-eval-raw-out

Conversation

@Xiretza

@Xiretza Xiretza commented May 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #7768.

Comment on lines +715 to +725
/// 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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should I separate the refactoring out to a separate commit? On the other hand, you seem to squash a lot anyway.

Comment on lines +31 to +37

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");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Did I miss any other tests for the CLI, or the ones in this file the only ones?

Comment on lines +25 to +30
EvalSerializationFormat::Json => {
println!("{}", crate::serialize(&value, SerializationFormat::Json, pretty)?);
}
EvalSerializationFormat::Yaml => {
println!("{}", crate::serialize(&value, SerializationFormat::Yaml, pretty)?);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nesting SerializationFormat inside EvalSerializationFormat would be nice here of course, but probably not nice enough to justify hand-coding ValueEnum.

@Xiretza Xiretza force-pushed the typst-eval-raw-out branch from 3832e2d to 32affe0 Compare May 15, 2026 18:07
@isuffix isuffix added the cli About Typst's command line interface. label May 17, 2026
@laurmaedje laurmaedje added the waiting-on-review This PR is waiting to be reviewed. label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli About Typst's command line interface. waiting-on-review This PR is waiting to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

typst eval: Support --format raw

3 participants