Skip to content

Commit

Permalink
Accept slash-t for tab as delimiter argument
Browse files Browse the repository at this point in the history
Currently to use a tab you must use:

$ csvlens -d $'\t' ...

With this change the following are also accepted:

$ csvlens -d '\t' ...
$ csvlens -d "\t" ...
  • Loading branch information
peterjc committed Jan 8, 2024
1 parent 3662a9f commit 158086a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/delimiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ impl Delimiter {
if s == "auto" {
return Ok(Delimiter::Auto);
}
if s == r"\t" {
return Ok(Delimiter::Character(b'\t'));
}
let mut chars = s.chars();
let c = chars.next().context("Delimiter should not be empty")?;
if !c.is_ascii() {
Expand All @@ -28,7 +31,7 @@ impl Delimiter {
);
}
if chars.next().is_some() {
bail!("Delimiter should be exactly one character, got {}", s);
bail!("Delimiter should be exactly one character (or \\t), got '{}'", s);
}
Ok(Delimiter::Character(c.try_into()?))
} else {
Expand Down

0 comments on commit 158086a

Please sign in to comment.