@@ -23,6 +23,7 @@ pub struct CreateScratchConfig {
2323 pub compiler_flags : String ,
2424 pub function_name : String ,
2525 pub target_obj : PathBuf ,
26+ pub preset_id : Option < u32 > ,
2627}
2728
2829impl CreateScratchConfig {
@@ -45,6 +46,7 @@ impl CreateScratchConfig {
4546 compiler_flags : scratch_config. c_flags . clone ( ) . unwrap_or_default ( ) ,
4647 function_name,
4748 target_obj : target_path. to_path_buf ( ) ,
49+ preset_id : scratch_config. preset_id ,
4850 } )
4951 }
5052
@@ -101,15 +103,18 @@ fn run_create_scratch(
101103 let obj_path = project_dir. join ( & config. target_obj ) ;
102104 let file = reqwest:: blocking:: multipart:: Part :: file ( & obj_path)
103105 . with_context ( || format ! ( "Failed to open {}" , obj_path. display( ) ) ) ?;
104- let form = reqwest:: blocking:: multipart:: Form :: new ( )
106+ let mut form = reqwest:: blocking:: multipart:: Form :: new ( )
105107 . text ( "compiler" , config. compiler . clone ( ) )
106108 . text ( "platform" , config. platform . clone ( ) )
107109 . text ( "compiler_flags" , config. compiler_flags . clone ( ) )
108110 . text ( "diff_label" , config. function_name . clone ( ) )
109111 . text ( "diff_flags" , diff_flags)
110112 . text ( "context" , context. unwrap_or_default ( ) )
111- . text ( "source_code" , "// Move related code from Context tab to here" )
112- . part ( "target_obj" , file) ;
113+ . text ( "source_code" , "// Move related code from Context tab to here" ) ;
114+ if let Some ( preset) = config. preset_id {
115+ form = form. text ( "preset" , preset. to_string ( ) ) ;
116+ }
117+ form = form. part ( "target_obj" , file) ;
113118 let client = reqwest:: blocking:: Client :: new ( ) ;
114119 let response = client
115120 . post ( formatcp ! ( "{API_HOST}/api/scratch" ) )
0 commit comments