11use std:: io:: Write ;
2+ use std:: ops:: Not ;
23
34use color_eyre:: eyre;
45use lib:: doc:: render:: ppi_to_ppp;
@@ -8,9 +9,9 @@ use termcolor::Color;
89use typst:: diag:: Warned ;
910use typst_syntax:: { FileId , Source , VirtualPath } ;
1011
11- use super :: { CompileArgs , Context , RenderArgs } ;
12+ use super :: { CompileArgs , Context , ExportArgs } ;
1213use crate :: cli:: OperationFailure ;
13- use crate :: ui ;
14+ use crate :: { ui , DEFAULT_OPTIMIZE_OPTIONS } ;
1415
1516#[ derive( clap:: Args , Debug , Clone ) ]
1617#[ group( id = "add-args" ) ]
@@ -34,7 +35,7 @@ pub struct Args {
3435 pub compile : CompileArgs ,
3536
3637 #[ command( flatten) ]
37- pub render : RenderArgs ,
38+ pub export : ExportArgs ,
3839
3940 /// The name of the test to add
4041 pub test : Id ,
@@ -72,11 +73,22 @@ pub fn run(ctx: &mut Context, args: &Args) -> eyre::Result<()> {
7273 } = Document :: compile (
7374 Source :: new ( FileId :: new_fake ( VirtualPath :: new ( "" ) ) , template. to_owned ( ) ) ,
7475 & world,
75- ppi_to_ppp ( args. render . pixel_per_inch ) ,
76+ ppi_to_ppp ( args. export . render . pixel_per_inch ) ,
7677 ) ;
7778 let doc = output?;
7879
79- Test :: create ( paths, id, template, Some ( Reference :: Persistent ( doc) ) ) ?;
80+ Test :: create (
81+ paths,
82+ id,
83+ template,
84+ Some ( Reference :: Persistent (
85+ doc,
86+ args. export
87+ . no_optimize_references
88+ . not ( )
89+ . then ( || Box :: new ( DEFAULT_OPTIMIZE_OPTIONS . clone ( ) ) ) ,
90+ ) ) ,
91+ ) ?;
8092 } ;
8193 } else {
8294 Test :: create_default ( paths, id) ?;
0 commit comments