File tree Expand file tree Collapse file tree 3 files changed +75
-1
lines changed Expand file tree Collapse file tree 3 files changed +75
-1
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " whitespace-sifter"
3
- version = " 2.3.6-alpha.1 "
3
+ version = " 2.3.6"
4
4
edition = " 2021"
5
5
authors = [" JumperBot_" ]
6
6
description = " Sift duplicate whitespaces away!"
@@ -16,3 +16,10 @@ test = true
16
16
doctest = true
17
17
doc = true
18
18
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" ] }
Original file line number Diff line number Diff line change @@ -98,16 +98,41 @@ Benchmark specifications:
98
98
99
99
---
100
100
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
+
101
124
## 🔊 Changelog
102
125
103
126
- Improved Performance
104
127
- Minimum Supported Rust Version set to ` v1.79.0 ` (starting ` v2.3.3 ` )
128
+ - Crate binary (starting ` v2.3.6 ` )
105
129
- Stricter Tests (starting ` v2.3.2 ` )
106
130
- Proper UTF-8/Unicode Encoding
107
131
- Regular Sifting
108
132
- Sifting With Leading Whitespaces
109
133
- Documentation Assertion
110
134
- MSRV Verification
135
+ - Compliance Check for Old Versions
111
136
- Crate Comparison (starting ` v2.3.4 ` )
112
137
- Benchmark Separation (starting ` v2.3.5 ` )
113
138
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments