@@ -23,6 +23,7 @@ pub struct CreateScratchConfig {
23
23
pub compiler_flags : String ,
24
24
pub function_name : String ,
25
25
pub target_obj : PathBuf ,
26
+ pub preset_id : Option < u32 > ,
26
27
}
27
28
28
29
impl CreateScratchConfig {
@@ -45,6 +46,7 @@ impl CreateScratchConfig {
45
46
compiler_flags : scratch_config. c_flags . clone ( ) . unwrap_or_default ( ) ,
46
47
function_name,
47
48
target_obj : target_path. to_path_buf ( ) ,
49
+ preset_id : scratch_config. preset_id ,
48
50
} )
49
51
}
50
52
@@ -101,15 +103,18 @@ fn run_create_scratch(
101
103
let obj_path = project_dir. join ( & config. target_obj ) ;
102
104
let file = reqwest:: blocking:: multipart:: Part :: file ( & obj_path)
103
105
. 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 ( )
105
107
. text ( "compiler" , config. compiler . clone ( ) )
106
108
. text ( "platform" , config. platform . clone ( ) )
107
109
. text ( "compiler_flags" , config. compiler_flags . clone ( ) )
108
110
. text ( "diff_label" , config. function_name . clone ( ) )
109
111
. text ( "diff_flags" , diff_flags)
110
112
. 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) ;
113
118
let client = reqwest:: blocking:: Client :: new ( ) ;
114
119
let response = client
115
120
. post ( formatcp ! ( "{API_HOST}/api/scratch" ) )
0 commit comments