File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,13 @@ struct Cli {
1717
1818fn main ( ) -> Result < ( ) , Error > {
1919 let cli = Cli :: parse ( ) ;
20- println ! ( "{}" , reports:: clone( cli. reports) ?. display( ) ) ;
20+ let reports_org_path = reports:: clone ( cli. reports ) ?;
21+ let reports_org_list = reports:: find ( reports_org_path) ?;
22+ for report in reports_org_list {
23+ dbg ! ( & report) ;
24+ let new_md_report = reports:: convert ( report) ?;
25+ dbg ! ( new_md_report) ;
26+ // add_report_to_website(new_md_report)?;
27+ }
2128 Ok ( ( ) )
2229}
Original file line number Diff line number Diff line change 11use std:: path:: PathBuf ;
2+ use std:: process:: Command ;
3+
4+ use std:: fs;
25
36use git2:: Repository ;
47use mktemp:: Temp ;
@@ -10,3 +13,28 @@ pub fn clone(reports_repo: String) -> Result<PathBuf, Error> {
1013 Repository :: clone ( & reports_repo, & path_to_repo) ?;
1114 Ok ( path_to_repo)
1215}
16+
17+ pub fn find ( reports_org_path : PathBuf ) -> Result < Vec < PathBuf > , Error > {
18+ let mut results = Vec :: new ( ) ;
19+ for entry in fs:: read_dir ( reports_org_path) ? {
20+ let entry = entry?;
21+ let path = entry. path ( ) ;
22+ if let Some ( Some ( "org" ) ) = path. extension ( ) . map ( |osstr| osstr. to_str ( ) ) {
23+ results. push ( path) ;
24+ }
25+ }
26+ Ok ( results)
27+ }
28+
29+ pub fn convert ( report_org_path : PathBuf ) -> Result < PathBuf , Error > {
30+ let mut report_md_path = report_org_path. clone ( ) ;
31+ report_md_path. set_extension ( "md" ) ;
32+ Command :: new ( "pandoc" )
33+ . arg ( "--from=org" )
34+ . arg ( "--to=gfm" )
35+ . arg ( report_org_path)
36+ . arg ( "-o" )
37+ . arg ( & report_md_path)
38+ . spawn ( ) ?;
39+ Ok ( report_md_path)
40+ }
You can’t perform that action at this time.
0 commit comments