-
Notifications
You must be signed in to change notification settings - Fork 174
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
Showing
3 changed files
with
71 additions
and
55 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 |
---|---|---|
|
@@ -3,20 +3,20 @@ | |
<br> | ||
|
||
[![build](https://github.com/pemistahl/grex/actions/workflows/build.yml/badge.svg)](https://github.com/pemistahl/grex/actions/workflows/build.yml) | ||
[![dependency status](https://deps.rs/crate/grex/1.4.0/status.svg)](https://deps.rs/crate/grex/1.4.0) | ||
[![dependency status](https://deps.rs/crate/grex/1.4.1/status.svg)](https://deps.rs/crate/grex/1.4.1) | ||
[![codecov](https://codecov.io/gh/pemistahl/grex/branch/main/graph/badge.svg)](https://codecov.io/gh/pemistahl/grex) | ||
[![lines of code](https://tokei.rs/b1/github/pemistahl/grex?category=code)](https://github.com/XAMPPRocky/tokei) | ||
[![Downloads](https://img.shields.io/crates/d/grex.svg)](https://crates.io/crates/grex) | ||
|
||
[![Docs.rs](https://docs.rs/grex/badge.svg)](https://docs.rs/grex) | ||
[![Crates.io](https://img.shields.io/crates/v/grex.svg)](https://crates.io/crates/grex) | ||
[![Lib.rs](https://img.shields.io/badge/lib.rs-v1.4.0-blue)](https://lib.rs/crates/grex) | ||
[![Lib.rs](https://img.shields.io/badge/lib.rs-v1.4.1-blue)](https://lib.rs/crates/grex) | ||
[![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) | ||
|
||
[![Linux Download](https://img.shields.io/badge/Linux%20Download-v1.4.0-blue?logo=Linux)](https://github.com/pemistahl/grex/releases/download/v1.4.0/grex-v1.4.0-x86_64-unknown-linux-musl.tar.gz) | ||
[![MacOS Download](https://img.shields.io/badge/macOS%20x86%20Download-v1.4.0-blue?logo=Apple)](https://github.com/pemistahl/grex/releases/download/v1.4.0/grex-v1.4.0-x86_64-apple-darwin.tar.gz) | ||
[![MacOS ARM Download](https://img.shields.io/badge/macOS%20ARM%20Download-v1.4.0-blue?logo=Apple)](https://github.com/pemistahl/grex/releases/download/v1.4.0/grex-v1.4.0-aarch64-apple-darwin.tar.gz) | ||
[![Windows Download](https://img.shields.io/badge/Windows%20Download-v1.4.0-blue?logo=Windows)](https://github.com/pemistahl/grex/releases/download/v1.4.0/grex-v1.4.0-x86_64-pc-windows-msvc.zip) | ||
[![Linux Download](https://img.shields.io/badge/Linux%20Download-v1.4.1-blue?logo=Linux)](https://github.com/pemistahl/grex/releases/download/v1.4.1/grex-v1.4.1-x86_64-unknown-linux-musl.tar.gz) | ||
[![MacOS Download](https://img.shields.io/badge/macOS%20x86%20Download-v1.4.1-blue?logo=Apple)](https://github.com/pemistahl/grex/releases/download/v1.4.1/grex-v1.4.1-x86_64-apple-darwin.tar.gz) | ||
[![MacOS ARM Download](https://img.shields.io/badge/macOS%20ARM%20Download-v1.4.1-blue?logo=Apple)](https://github.com/pemistahl/grex/releases/download/v1.4.1/grex-v1.4.1-aarch64-apple-darwin.tar.gz) | ||
[![Windows Download](https://img.shields.io/badge/Windows%20Download-v1.4.1-blue?logo=Windows)](https://github.com/pemistahl/grex/releases/download/v1.4.1/grex-v1.4.1-x86_64-pc-windows-msvc.zip) | ||
|
||
<br> | ||
|
||
|
@@ -109,7 +109,7 @@ In order to use *grex* as a library, simply add it as a dependency to your `Carg | |
|
||
```toml | ||
[dependencies] | ||
grex = { version = "1.4.0", default-features = false } | ||
grex = { version = "1.4.1", default-features = false } | ||
``` | ||
|
||
The dependencies `clap` and `atty` are only needed for the command-line tool. | ||
|
@@ -130,65 +130,72 @@ The following table shows all available flags and options: | |
``` | ||
$ grex -h | ||
grex 1.4.0 | ||
grex 1.4.1 | ||
© 2019-today Peter M. Stahl <[email protected]> | ||
Licensed under the Apache License, Version 2.0 | ||
Downloadable from https://crates.io/crates/grex | ||
Source code at https://github.com/pemistahl/grex | ||
grex generates regular expressions from user-provided test cases. | ||
USAGE: | ||
grex [OPTIONS] [INPUT]... | ||
Usage: grex [OPTIONS] {INPUT...|--file <FILE>} | ||
Input: | ||
[INPUT]... One or more test cases separated by blank space | ||
-f, --file <FILE> Reads test cases on separate lines from a file | ||
Digit Options: | ||
-d, --digits Converts any Unicode decimal digit to \d | ||
-D, --non-digits Converts any character which is not a Unicode decimal digit to \D | ||
Whitespace Options: | ||
-s, --spaces Converts any Unicode whitespace character to \s | ||
-S, --non-spaces Converts any character which is not a Unicode whitespace character to \S | ||
Word Options: | ||
-w, --words Converts any Unicode word character to \w | ||
-W, --non-words Converts any character which is not a Unicode word character to \W | ||
Escaping Options: | ||
-e, --escape Replaces all non-ASCII characters with unicode escape sequences | ||
--with-surrogates Converts astral code points to surrogate pairs if --escape is set | ||
Repetition Options: | ||
-r, --repetitions | ||
Detects repeated non-overlapping substrings and converts them to {min,max} quantifier | ||
notation | ||
--min-repetitions <QUANTITY> | ||
Specifies the minimum quantity of substring repetitions to be converted if --repetitions | ||
is set [default: 1] | ||
--min-substring-length <LENGTH> | ||
Specifies the minimum length a repeated substring must have in order to be converted if | ||
--repetitions is set [default: 1] | ||
Anchor Options: | ||
--no-start-anchor Removes the caret anchor `^` from the resulting regular expression | ||
--no-end-anchor Removes the dollar sign anchor `$` from the resulting regular expression | ||
--no-anchors Removes the caret and dollar sign anchors from the resulting regular | ||
expression | ||
Display Options: | ||
-x, --verbose Produces a nicer-looking regular expression in verbose mode | ||
-c, --colorize Provides syntax highlighting for the resulting regular expression | ||
Miscellaneous Options: | ||
-i, --ignore-case Performs case-insensitive matching, letters match both upper and lower case | ||
-g, --capture-groups Replaces non-capturing groups with capturing ones | ||
-h, --help Prints help information | ||
-v, --version Prints version information | ||
INPUT: | ||
<INPUT>... One or more test cases separated by blank space | ||
-f, --file <FILE> Reads test cases on separate lines from a file | ||
DIGIT OPTIONS: | ||
-d, --digits Converts any Unicode decimal digit to \d | ||
-D, --non-digits Converts any character which is not a Unicode decimal digit to \D | ||
WHITESPACE OPTIONS: | ||
-s, --spaces Converts any Unicode whitespace character to \s | ||
-S, --non-spaces Converts any character which is not a Unicode whitespace character to \S | ||
WORD OPTIONS: | ||
-w, --words Converts any Unicode word character to \w | ||
-W, --non-words Converts any character which is not a Unicode word character to \W | ||
ESCAPING OPTIONS: | ||
-e, --escape Replaces all non-ASCII characters with unicode escape sequences | ||
--with-surrogates Converts astral code points to surrogate pairs if --escape is set | ||
REPETITION OPTIONS: | ||
-r, --repetitions Detects repeated non-overlapping substrings and converts them to {min,max} quantifier notation | ||
--min-repetitions <QUANTITY> Specifies the minimum quantity of substring repetitions to be converted if --repetitions is set [default: 1] | ||
--min-substring-length <LENGTH> Specifies the minimum length a repeated substring must have in order to be converted if --repetitions is set [default: 1] | ||
ANCHOR OPTIONS: | ||
--no-anchors Removes the caret and dollar sign anchors from the resulting regular expression | ||
--no-end-anchor Removes the dollar sign anchor `$` from the resulting regular expression | ||
--no-start-anchor Removes the caret anchor `^` from the resulting regular expression | ||
DISPLAY OPTIONS: | ||
-x, --verbose Produces a nicer-looking regular expression in verbose mode | ||
-c, --colorize Provides syntax highlighting for the resulting regular expression | ||
MISCELLANEOUS OPTIONS: | ||
-i, --ignore-case Performs case-insensitive matching, letters match both upper and lower case | ||
-g, --capture-groups Replaces non-capturing groups with capturing ones | ||
-h, --help Print help information | ||
-v, --version Print version information | ||
``` | ||
|
||
### 5.2 The library | ||
|
||
#### 5.2.1 Default settings | ||
|
||
Test cases are passed either from a collection via [`RegExpBuilder::from()`](https://docs.rs/grex/1.4.0/grex/struct.RegExpBuilder.html#method.from) | ||
or from a file via [`RegExpBuilder::from_file()`](https://docs.rs/grex/1.4.0/grex/struct.RegExpBuilder.html#method.from_file). | ||
Test cases are passed either from a collection via [`RegExpBuilder::from()`](https://docs.rs/grex/1.4.1/grex/struct.RegExpBuilder.html#method.from) | ||
or from a file via [`RegExpBuilder::from_file()`](https://docs.rs/grex/1.4.1/grex/struct.RegExpBuilder.html#method.from_file). | ||
If read from a file, each test case must be on a separate line. Lines may be ended with either a newline `\n` or a carriage | ||
return with a line feed `\r\n`. | ||
|
||
|
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
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 |
---|---|---|
|
@@ -27,9 +27,9 @@ mod cli { | |
#[command( | ||
author = "© 2019-today Peter M. Stahl <[email protected]>", | ||
about = "Licensed under the Apache License, Version 2.0\n\ | ||
Downloadable from https://crates.io/crates/grex\n\ | ||
Source code at https://github.com/pemistahl/grex\n\n\ | ||
grex generates regular expressions from user-provided test cases.", | ||
Downloadable from https://crates.io/crates/grex\n\ | ||
Source code at https://github.com/pemistahl/grex\n\n\ | ||
grex generates regular expressions from user-provided test cases.", | ||
version, | ||
override_usage = "grex [OPTIONS] {INPUT...|--file <FILE>}", | ||
help_template = "{name} {version}\n{author}\n{about}\n\n{usage-heading} {usage}\n\n{all-args}", | ||
|
@@ -58,7 +58,7 @@ mod cli { | |
/// Lines may be ended with either a newline `\n` or a carriage return with a line feed `\r\n`. | ||
/// The final line ending is optional. | ||
/// | ||
/// Conflicts with [INPUT]... | ||
/// Conflicts with INPUT... | ||
#[arg( | ||
name = "file", | ||
value_name = "FILE", | ||
|