-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ecad8fb
Showing
5 changed files
with
469 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
__data |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "condense" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
clap = { version = "4.5.4", features = ["derive"] } | ||
regex = "1.10.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Condense | ||
Condense the white space in a text file. | ||
I feel like I always run into a collection of text files that for one reason or another are filled to the gills | ||
with terrible white space. | ||
This cli utility helps to condense these files and remove duplicative white space characters. | ||
|
||
## Usage | ||
Condense a string from `stdin` or read a file in. | ||
If modifying a file, pass the `--inplace` flag to modify the file where it is. | ||
|
||
```bash | ||
$ condense --help | ||
Remove repetitive white space characters | ||
|
||
Usage: condense [OPTIONS] [DATA] | ||
|
||
Arguments: | ||
[DATA] An input string to condense | ||
|
||
Options: | ||
-f, --file <FILE> Should read from file instead of stdin | ||
-a, --aggressive Whether to consider all consecutive white spaces as duplicates | ||
--one aggressivly condense input to one line with only single spaces | ||
-i, --inplace If sent a file file, edit in place | ||
-h, --help Print help | ||
-V, --version Print version | ||
``` | ||
You can run the util over every file in a directory with | ||
|
||
```bash | ||
find <my_dir> -type f -print | xargs -I {} ./condense -f {} | ||
``` | ||
|
||
And if you use [Parallel](https://www.gnu.org/software/parallel/), then you should be able to | ||
do the following to condense ever file in a directory concurrently | ||
|
||
```bash | ||
# I haven't tested this yet | ||
find <my_dir> -type f -print | parallel -j4 ./condense -f {} | ||
``` |
Oops, something went wrong.