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 clap::Parser;
|
||||||
use std::{io, fs, path::PathBuf};
|
use std::{io, fs, path::PathBuf};
|
||||||
|
//TODO: implement mod file_tree :ODOT//
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(name = "YUNODO")]
|
#[command(name = "YUNODO")]
|
||||||
#[command(version = "0.3.0")]
|
#[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)
|
Ok(files_content)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
if let Some(path) = cli.path.as_deref() {
|
if let Some(path) = cli.path.as_deref() {
|
||||||
|
|
@ -151,11 +150,8 @@ fn main() {
|
||||||
if let Some(end_index) = last_part.find(":ODOT//") {
|
if let Some(end_index) = last_part.find(":ODOT//") {
|
||||||
let extracted = &last_part[..end_index];
|
let extracted = &last_part[..end_index];
|
||||||
// Format output CSV item
|
// Format output CSV item
|
||||||
if !output_csv_item.is_empty(){
|
//TODO:Call format_csv fn:ODOT//
|
||||||
output_csv_item = format!("{},path:\"{}\",file_name:\"{}\",line_number:\"{}\",comment:\"{}\"", output_csv_item, path_string, filename, line_number + 1, extracted);
|
format_csv(output_csv_item, path_string,&filename, line_number, extracted.to_string());
|
||||||
} else {
|
|
||||||
output_csv_item = format!("path:\"{}\",file_name:\"{}\",line_number:\"{}\",comment:\"{}\"",path_string, filename, line_number + 1, extracted);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -169,3 +165,10 @@ fn main() {
|
||||||
println!("{}",output_csv_item)
|
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