File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515use std:: path:: PathBuf ;
1616
1717use clap:: Parser ;
18+ use walkdir:: WalkDir ;
1819
1920use crate :: error:: Fallible ;
2021use crate :: error:: fail;
@@ -41,6 +42,13 @@ pub fn entrypoint() -> Fallible<()> {
4142 if !directory. exists ( ) {
4243 return fail ( "directory does not exist." ) ;
4344 }
45+ for entry in WalkDir :: new ( directory) {
46+ let entry = entry?;
47+ let path = entry. path ( ) ;
48+ if path. is_file ( ) && path. extension ( ) . map_or ( false , |ext| ext == "md" ) {
49+ let contents = std:: fs:: read_to_string ( path) ?;
50+ }
51+ }
4452 Ok ( ( ) )
4553 }
4654 }
Original file line number Diff line number Diff line change @@ -27,6 +27,14 @@ impl From<std::io::Error> for ErrorReport {
2727 }
2828}
2929
30+ impl From < walkdir:: Error > for ErrorReport {
31+ fn from ( value : walkdir:: Error ) -> Self {
32+ ErrorReport {
33+ message : format ! ( "directory traversal error: {value:#?}" ) ,
34+ }
35+ }
36+ }
37+
3038impl Display for ErrorReport {
3139 // This trait requires `fmt` with this exact signature.
3240 fn fmt ( & self , f : & mut Formatter ) -> std:: fmt:: Result {
You can’t perform that action at this time.
0 commit comments