From cddfae5953c4adc65af6985851da02e25002dfe5 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Fri, 27 Oct 2023 09:58:07 +0200 Subject: [PATCH] add --noheader option --- src/args.rs | 1 + src/main.rs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/args.rs b/src/args.rs index e971d87..72b9c3d 100644 --- a/src/args.rs +++ b/src/args.rs @@ -26,5 +26,6 @@ pub fn get_args() -> ArgMatches { .arg(arg!(-s --sortby "Sort results based on specified key").required(false)) .arg(arg!(-g --groupby "Group results based on specified key").required(false)) .arg(arg!(-r --reverse "Reverse the results").required(false)) + .arg(arg!(--noheader "Dont print header in CSV mode. Useful for scripting").required(false)) .get_matches() } diff --git a/src/main.rs b/src/main.rs index a95b961..5664764 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,8 @@ fn main() { let output_json = args.get_flag("json"); + let no_header = args.get_flag("noheader"); + let limit: usize = args.get_one::("limit").unwrap().parse().unwrap(); let offset: usize = args.get_one::("offset").unwrap().parse().unwrap(); @@ -99,7 +101,7 @@ fn main() { let mut first = true; for (_, val) in grouped { if first { - print_csv(val, Some(&headers)); + print_csv(val, if no_header { None } else { Some(&headers) }); first = false; continue; } @@ -129,7 +131,7 @@ fn main() { if std::io::stdout().is_terminal() { print_result(data, &headers); } else { - print_csv(data, Some(&headers)); + print_csv(data, if no_header { None } else { Some(&headers) }); } }