Skip to content

Commit

Permalink
add -t for tsv files
Browse files Browse the repository at this point in the history
  • Loading branch information
JojiiOfficial committed Jan 8, 2024
1 parent 3662a9f commit 08ee1c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/delimiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ pub enum Delimiter {

impl Delimiter {
/// Create a Delimiter by parsing the command line argument for the delimiter
pub fn from_arg(delimiter_arg: &Option<String>) -> Result<Self> {
pub fn from_arg(delimiter_arg: &Option<String>, tab_separation: bool) -> Result<Self> {
if tab_separation {
return Ok(Delimiter::Character('\t'.try_into()?));
}

if let Some(s) = delimiter_arg {
if s == "auto" {
return Ok(Delimiter::Auto);
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod ui;
mod util;
mod view;
mod wrap;

use crate::app::App;
use crate::delimiter::Delimiter;

Expand Down Expand Up @@ -98,6 +99,10 @@ struct Args {
#[clap(short, long)]
delimiter: Option<String>,

/// Use tab separation. Shortcut for -d '<TAB>'.
#[clap(short = 't', long)]
tab_separated: bool,

/// Searches ignore case. Ignored if any uppercase letters are present in the search string
#[clap(short, long)]
ignore_case: bool,
Expand Down Expand Up @@ -158,7 +163,7 @@ fn run_csvlens() -> Result<Option<String>> {
let args = Args::parse();

let show_stats = args.debug;
let delimiter = Delimiter::from_arg(&args.delimiter)?;
let delimiter = Delimiter::from_arg(&args.delimiter, args.tab_separated)?;

let file = SeekableFile::new(&args.filename)?;
let filename = file.filename();
Expand Down

0 comments on commit 08ee1c4

Please sign in to comment.