File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 1- use anyhow:: { Context , Result } ;
1+ use anyhow:: Context ;
22use minijinja:: Environment ;
3- use std:: path:: PathBuf ;
4- use std:: { env, fs} ;
3+ use std:: { collections:: HashMap , env, fs, process} ;
54
6- fn main ( ) -> Result < ( ) > {
5+ fn main ( ) -> anyhow :: Result < ( ) > {
76 let mut args = env:: args ( ) ;
87 if args. len ( ) != 2 {
98 let name = args. next ( ) . unwrap ( ) ;
109 eprintln ! ( "Usage: {} <template_file>" , name) ;
11- std :: process:: exit ( 1 ) ;
10+ process:: exit ( 1 ) ;
1211 }
1312
14- let template_path = PathBuf :: from ( args. nth ( 1 ) . unwrap ( ) ) ;
15- let template = fs:: read_to_string ( & template_path )
16- . with_context ( || format ! ( "Failed to read template file: {}" , template_path . display ( ) ) ) ?;
13+ let path = args. nth ( 1 ) . unwrap ( ) ;
14+ let template = fs:: read_to_string ( & path )
15+ . with_context ( || format ! ( "Failed to read template file: {}" , path ) ) ?;
1716
1817 let mut env = Environment :: new ( ) ;
1918 env. add_template ( "template" , & template) ?;
2019
2120 let tmpl = env. get_template ( "template" ) ?;
22- let ctx = env:: vars ( ) . collect :: < std :: collections :: HashMap < _ , _ > > ( ) ;
21+ let ctx = env:: vars ( ) . collect :: < HashMap < _ , _ > > ( ) ;
2322
2423 let output = tmpl. render ( & ctx) ?;
2524 println ! ( "{}" , output) ;
You can’t perform that action at this time.
0 commit comments