extracted format_csv
This commit is contained in:
parent
67294d5e84
commit
3578cfe932
1 changed files with 10 additions and 7 deletions
17
src/main.rs
17
src/main.rs
|
|
@ -56,7 +56,7 @@
|
|||
//! ```
|
||||
use clap::Parser;
|
||||
use std::{io, fs, path::PathBuf};
|
||||
|
||||
//TODO: implement mod file_tree :ODOT//
|
||||
#[derive(Parser)]
|
||||
#[command(name = "YUNODO")]
|
||||
#[command(version = "0.3.0")]
|
||||
|
|
@ -102,7 +102,6 @@ fn read_files_in_directory(dir_path: &str) -> io::Result<Vec<(String, Vec<String
|
|||
|
||||
Ok(files_content)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
if let Some(path) = cli.path.as_deref() {
|
||||
|
|
@ -151,11 +150,8 @@ fn main() {
|
|||
if let Some(end_index) = last_part.find(":ODOT//") {
|
||||
let extracted = &last_part[..end_index];
|
||||
// Format output CSV item
|
||||
if !output_csv_item.is_empty(){
|
||||
output_csv_item = format!("{},path:\"{}\",file_name:\"{}\",line_number:\"{}\",comment:\"{}\"", output_csv_item, path_string, filename, line_number + 1, extracted);
|
||||
} else {
|
||||
output_csv_item = format!("path:\"{}\",file_name:\"{}\",line_number:\"{}\",comment:\"{}\"",path_string, filename, line_number + 1, extracted);
|
||||
}
|
||||
//TODO:Call format_csv fn:ODOT//
|
||||
format_csv(output_csv_item, path_string,&filename, line_number, extracted.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -169,3 +165,10 @@ fn main() {
|
|||
println!("{}",output_csv_item)
|
||||
}
|
||||
}
|
||||
fn format_csv(output:String,path:String,filename:&String,line_number:usize,comment:String){
|
||||
if !output.is_empty(){
|
||||
output = format!("{},path:\"{}\",file_name:\"{}\",line_number:\"{}\",comment:\"{}\"", output, path, filename, line_number + 1, comment);
|
||||
} else {
|
||||
output = format!("path:\"{}\",file_name:\"{}\",line_number:\"{}\",comment:\"{}\"",path, filename, line_number + 1, comment);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue