added format match statement
This commit is contained in:
parent
5ab28f4501
commit
a8fbe32ea5
1 changed files with 13 additions and 7 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -6,13 +6,13 @@ use std::{io, fs, path::PathBuf,collections::HashMap};
|
||||||
#[command(version = "0.5.0")]
|
#[command(version = "0.5.0")]
|
||||||
#[command(about = "parse file tree for //TODO: comments", long_about = "parses a directory of files for substrings of //TODO: and outputs all instances in a parsable format")]
|
#[command(about = "parse file tree for //TODO: comments", long_about = "parses a directory of files for substrings of //TODO: and outputs all instances in a parsable format")]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Sets a custom config file
|
|
||||||
#[arg(short, long, value_name = "PATH")]
|
#[arg(short, long, value_name = "PATH")]
|
||||||
path: Option<PathBuf>,
|
path: Option<PathBuf>,
|
||||||
#[arg(short, long, value_name = "DEBUG")]
|
#[arg(short, long, value_name = "FORMAT")]
|
||||||
|
format: Option<String>,
|
||||||
|
#[arg(short, long)]
|
||||||
debug: Option<bool>,
|
debug: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
||||||
|
|
@ -78,10 +78,16 @@ fn main() {
|
||||||
eprintln!("Error: {}", err);
|
eprintln!("Error: {}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out_as_md_table(output_csv_item.clone());
|
if let Some(format) = cli.format.as_deref() {
|
||||||
out_as_json_object(output_csv_item.clone());
|
//TODO: write match to match format and select which output :ODOT//
|
||||||
out_as_toml_file(output_csv_item.clone());
|
match format {
|
||||||
out_as_yaml_file(output_csv_item.clone());
|
"md"|"MD" => out_as_md_table(output_csv_item.clone()),
|
||||||
|
"json"|"JSON" => out_as_json_object(output_csv_item.clone()),
|
||||||
|
"yaml"|"YAML" => out_as_yaml_file(output_csv_item.clone()),
|
||||||
|
"toml"|"TOML" => out_as_toml_file(output_csv_item.clone()),
|
||||||
|
_ => println!("That's not a supported format")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue