Skip to content

Commit 28730c5

Browse files
committed
✨ v2.3.6
1 parent 75c3468 commit 28730c5

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "whitespace-sifter"
3-
version = "2.3.6-alpha.1"
3+
version = "2.3.6"
44
edition = "2021"
55
authors = ["JumperBot_"]
66
description = "Sift duplicate whitespaces away!"
@@ -16,3 +16,10 @@ test = true
1616
doctest = true
1717
doc = true
1818
crate-type = ["lib"]
19+
20+
[[bin]]
21+
name = "whitespace-sifter"
22+
path = "src/main.rs"
23+
24+
[dependencies]
25+
clap = { version = "4.5.39", features = ["derive"] }

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,41 @@ Benchmark specifications:
9898

9999
---
100100

101+
## ➕ Dependency
102+
103+
Add this to your project with:
104+
105+
```bash
106+
$ cargo add whitespace-sifter
107+
```
108+
109+
## 📦️ Installation
110+
111+
Download the binary with:
112+
113+
```bash
114+
$ cargo install whitespace-sifter
115+
```
116+
117+
Use it as usual:
118+
119+
```bash
120+
$ echo "Hello there!" | whitespace-sifter
121+
$ cat document.txt | whitespace-sifter --preserve-newlines
122+
```
123+
101124
## 🔊 Changelog
102125

103126
- Improved Performance
104127
- Minimum Supported Rust Version set to `v1.79.0` (starting `v2.3.3`)
128+
- Crate binary (starting `v2.3.6`)
105129
- Stricter Tests (starting `v2.3.2`)
106130
- Proper UTF-8/Unicode Encoding
107131
- Regular Sifting
108132
- Sifting With Leading Whitespaces
109133
- Documentation Assertion
110134
- MSRV Verification
135+
- Compliance Check for Old Versions
111136
- Crate Comparison (starting `v2.3.4`)
112137
- Benchmark Separation (starting `v2.3.5`)
113138

src/main.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use clap::Parser;
2+
use std::io::Read;
3+
use whitespace_sifter::WhitespaceSifter;
4+
5+
#[derive(Parser)]
6+
#[command(
7+
name = "whitespace-sifter",
8+
about = "Sift duplicate whitespaces away!",
9+
author = "JumperBot_",
10+
version
11+
)]
12+
struct Args {
13+
/// Reads from stdin if omitted
14+
input: Option<String>,
15+
16+
/// Preserve newlines
17+
#[arg(long)]
18+
preserve_newlines: bool,
19+
}
20+
21+
fn main() {
22+
let args: Args = Args::parse();
23+
24+
let input: String = match args.input {
25+
Some(val) => val,
26+
None => {
27+
let mut buf = String::new();
28+
if let Err(err) = std::io::stdin().read_to_string(&mut buf) {
29+
eprintln!("Error reading from stdin: {err}");
30+
std::process::exit(1);
31+
}
32+
buf
33+
}
34+
};
35+
36+
if args.preserve_newlines {
37+
print!("{}", input.sift_preserve_newlines());
38+
return;
39+
}
40+
41+
print!("{}", input.sift());
42+
}

0 commit comments

Comments
 (0)