File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -34,14 +34,28 @@ impl<'a> ChiselModule<'a> for Snip {
3434 }
3535}
3636
37+ // TODO: consider making this a generic helper?
38+ fn check_bool_option ( config : & HashMap < String , String > , option : & str , default : bool ) -> bool {
39+ if let Some ( value) = config. get ( option) {
40+ value == "true"
41+ } else {
42+ default
43+ }
44+ }
45+
3746impl ModuleConfig for Snip {
3847 fn with_defaults ( ) -> Result < Self , ModuleError > {
3948 Ok ( Snip :: new ( ) )
4049 }
4150
42- fn with_config ( _config : & HashMap < String , String > ) -> Result < Self , ModuleError > {
43- // FIXME: expose the options
44- Err ( ModuleError :: NotSupported )
51+ fn with_config ( config : & HashMap < String , String > ) -> Result < Self , ModuleError > {
52+ let mut options = wasm_snip:: Options :: default ( ) ;
53+ options. snip_rust_fmt_code = check_bool_option ( & config, "snip_rust_fmt_code" , true ) ;
54+ options. snip_rust_panicking_code =
55+ check_bool_option ( & config, "snip_rust_panicking_code" , true ) ;
56+ options. skip_producers_section =
57+ check_bool_option ( & config, "skip_producers_section" , true ) ;
58+ Ok ( Snip { 0 : options } )
4559 }
4660}
4761
You can’t perform that action at this time.
0 commit comments