1+ use anyhow:: Result ;
12use inquire;
23use minijinja;
34use regex:: Regex ;
45use serde;
56use std:: fmt;
7+ use tracing:: { debug, error, info, trace, warn} ;
8+
9+ use crate :: utils:: render_strict;
610
711pub mod example_values;
812pub mod templates;
913
10- #[ derive( serde:: Serialize , Default ) ]
14+ #[ derive( serde:: Serialize , Default , Debug ) ]
1115pub struct InitVars {
1216 pub flag_regex : String ,
1317 pub registry_domain : String ,
@@ -22,7 +26,7 @@ pub struct InitVars {
2226 pub profiles : Vec < Profile > ,
2327}
2428
25- #[ derive( Clone , serde:: Serialize , Default ) ]
29+ #[ derive( Clone , serde:: Serialize , Default , Debug ) ]
2630pub struct Points {
2731 pub difficulty : String ,
2832 pub min : String ,
@@ -39,7 +43,7 @@ impl fmt::Display for Points {
3943 }
4044}
4145
42- #[ derive( serde:: Serialize , Default ) ]
46+ #[ derive( serde:: Serialize , Default , Debug ) ]
4347pub struct Profile {
4448 pub profile_name : String ,
4549 pub frontend_url : String ,
@@ -274,10 +278,12 @@ pub fn interactive_init() -> inquire::error::InquireResult<InitVars> {
274278}
275279
276280pub fn blank_init ( ) -> InitVars {
281+ trace ! ( "building blank config" ) ;
277282 InitVars :: default ( )
278283}
279284
280285pub fn example_init ( ) -> InitVars {
286+ trace ! ( "building example values config" ) ;
281287 InitVars {
282288 flag_regex : String :: from ( example_values:: FLAG_REGEX ) ,
283289 registry_domain : String :: from ( example_values:: REGISTRY_DOMAIN ) ,
@@ -315,6 +321,7 @@ pub fn example_init() -> InitVars {
315321 }
316322}
317323
318- pub fn templatize_init ( options : InitVars ) -> String {
319- minijinja:: render!( templates:: RCDS , options)
324+ pub fn templatize_init ( options : InitVars ) -> Result < String > {
325+ debug ! ( "rendering template with {options:?}" ) ;
326+ render_strict ( templates:: RCDS , minijinja:: context! { options} )
320327}
0 commit comments