Skip to content

Commit

Permalink
sniff: add --just-mime option which is a synonym of --no-infer
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Oct 18, 2023
1 parent c13c341 commit 0b2880d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cmd/sniff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ sniff options:
(Unsigned, Signed => Integer, Text => String, everything else the same)
--no-infer Do not infer the schema. Only return the file's mime type, size and
last modified date. Use this to use sniff as a general mime type detector.
Note that CSV and TSV files will only be detected as mime type plain/text
in this mode.
--just-mime Only return the file's mime type. Use this to use sniff as a general
mime type detector. Synonym for --no-infer.
--quick When sniffing a non-CSV remote file, only download the first chunk of the file
before attempting to detect the mime type. This is faster but less accurate as
some mime types cannot be detected with just the first downloaded chunk.
Expand Down Expand Up @@ -139,6 +143,7 @@ struct Args {
flag_user_agent: Option<String>,
flag_stats_types: bool,
flag_no_infer: bool,
flag_just_mime: bool,
flag_quick: bool,
flag_harvest_mode: bool,
}
Expand Down Expand Up @@ -714,6 +719,10 @@ async fn sniff_main(mut args: Args) -> CliResult<()> {
Some("CKAN-harvest/$QSV_VERSION ($QSV_TARGET; $QSV_BIN_NAME)".to_string());
}

if args.flag_just_mime {
args.flag_no_infer = true;
}

let mut sample_size = args.flag_sample;
if sample_size < 0.0 {
if args.flag_json || args.flag_pretty_json {
Expand Down

0 comments on commit 0b2880d

Please sign in to comment.