From 9df85e65dedf130981ab430764b4a4cdc9382dc8 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 11 Jan 2025 21:29:25 -0500 Subject: [PATCH] feat: add `template` command to qsvdp binary variant --- src/cmd/mod.rs | 2 +- src/cmd/template.rs | 8 +++++++- src/maindp.rs | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index 6b1ea16ab..be4ea95da 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -98,7 +98,7 @@ pub mod sqlp; pub mod stats; #[cfg(any(feature = "feature_capable", feature = "lite"))] pub mod table; -#[cfg(feature = "feature_capable")] +#[cfg(any(feature = "feature_capable", feature = "datapusher_plus"))] pub mod template; #[cfg(all(feature = "to", feature = "feature_capable"))] pub mod to; diff --git a/src/cmd/template.rs b/src/cmd/template.rs index e9883adf3..65896f8c0 100644 --- a/src/cmd/template.rs +++ b/src/cmd/template.rs @@ -128,6 +128,7 @@ use std::{ }; use ahash::{HashMap, HashMapExt}; +#[cfg(any(feature = "feature_capable", feature = "lite"))] use indicatif::{ProgressBar, ProgressDrawTarget}; use minijinja::{value::ValueKind, Environment, Value}; use minijinja_contrib::pycompat::unknown_method_callback; @@ -162,6 +163,7 @@ struct Args { flag_batch: usize, flag_delimiter: Option, flag_no_headers: bool, + #[allow(dead_code)] flag_progressbar: bool, flag_timeout: u16, flag_cache_dir: String, @@ -342,10 +344,12 @@ pub fn run(argv: &[&str]) -> CliResult<()> { let batchsize = util::optimal_batch_size(&rconfig, args.flag_batch, num_jobs); // prep progress bar + #[cfg(any(feature = "feature_capable", feature = "lite"))] let show_progress = (args.flag_progressbar || util::get_envvar_flag("QSV_PROGRESSBAR")) && !rconfig.is_stdin(); - + #[cfg(any(feature = "feature_capable", feature = "lite"))] let progress = ProgressBar::with_draw_target(None, ProgressDrawTarget::stderr_with_hz(5)); + #[cfg(any(feature = "feature_capable", feature = "lite"))] if show_progress { util::prep_progress(&progress, rowcount); } else { @@ -567,6 +571,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { } } + #[cfg(any(feature = "feature_capable", feature = "lite"))] if show_progress { progress.inc(batch.len() as u64); } @@ -574,6 +579,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { batch.clear(); } // end batch loop + #[cfg(any(feature = "feature_capable", feature = "lite"))] if show_progress { util::finish_progress(&progress); } diff --git a/src/maindp.rs b/src/maindp.rs index ea7113b58..f08dd8489 100644 --- a/src/maindp.rs +++ b/src/maindp.rs @@ -85,6 +85,7 @@ static COMMAND_LIST: &str = r#" sortcheck Check if a CSV is sorted sqlp Run a SQL query against several CSVs using the Pola.rs engine stats Infer data types and compute summary statistics + template Render templates using CSV data validate Validate CSV data for RFC4180-compliance or with JSON Schema NOTE: qsvdp ignores the --progressbar option for all commands."#; @@ -277,6 +278,7 @@ enum Command { #[cfg(feature = "polars")] SqlP, Stats, + Template, Validate, } @@ -336,6 +338,7 @@ impl Command { #[cfg(feature = "polars")] Command::SqlP => cmd::sqlp::run(argv), Command::Stats => cmd::stats::run(argv), + Command::Template => cmd::template::run(argv), Command::Validate => cmd::validate::run(argv), } }