diff --git a/src/cmd/schema.rs b/src/cmd/schema.rs index 76ef01887..ae860438c 100644 --- a/src/cmd/schema.rs +++ b/src/cmd/schema.rs @@ -133,7 +133,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { // build schema for each field by their inferred type, min/max value/length, and unique values let mut properties_map: Map = - match infer_schema_from_stats(&args, &input_filename) { + match infer_schema_from_stats(&args, &input_filename, false) { Ok(map) => map, Err(e) => { return fail_clierror!( @@ -209,6 +209,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { pub fn infer_schema_from_stats( args: &util::SchemaArgs, input_filename: &str, + quiet: bool, ) -> CliResult> { // invoke cmd::stats let (csv_fields, csv_stats) = util::get_stats_records(args, StatsMode::Schema)?; @@ -404,14 +405,18 @@ pub fn infer_schema_from_stats( if enum_list.is_empty() { if const_value != Value::Null { field_map.insert("const".to_string(), const_value.clone()); - winfo!("Const generated for field '{header_string}': {const_value:?}"); + if !quiet { + winfo!("Const generated for field '{header_string}': {const_value:?}"); + } } } else { field_map.insert("enum".to_string(), Value::Array(enum_list.clone())); - winfo!( - "Enum list generated for field '{header_string}' ({} value/s)", - enum_list.len() - ); + if !quiet { + winfo!( + "Enum list generated for field '{header_string}' ({} value/s)", + enum_list.len() + ); + } } // add current field definition to properties map diff --git a/src/cmd/tojsonl.rs b/src/cmd/tojsonl.rs index d95dc2999..2448e457c 100644 --- a/src/cmd/tojsonl.rs +++ b/src/cmd/tojsonl.rs @@ -41,6 +41,7 @@ Common options: -o, --output Write output to instead of stdout. --memcheck Check if there is enough memory to load the entire CSV into memory using CONSERVATIVE heuristics. + -Q, --quiet Do not display enum/const list inferencing messages. "#; use std::{fmt::Write, path::PathBuf, str::FromStr}; @@ -69,6 +70,7 @@ struct Args { flag_delimiter: Option, flag_output: Option, flag_memcheck: bool, + flag_quiet: bool, } impl From for CliError { @@ -144,7 +146,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { }; // build schema for each field by their inferred type, min/max value/length, and unique values let properties_map: Map = - match infer_schema_from_stats(&schema_args, &input_filename) { + match infer_schema_from_stats(&schema_args, &input_filename, args.flag_quiet) { Ok(map) => map, Err(e) => { return fail_clierror!("Failed to infer field types: {e}");