Repository: pemistahl/grex (language: rust)

Issue:
Add optional CLI feature if using grex as a library
Hi @pemistahl, first off, thanks for this wonderful library!  

But would it be possible to have an optional CLI feature in cargo.toml?

In that way, if I'm using grex as a library, I don't need to get dependencies like structopt  included in my project. 


Discussion / hints:
Thanks for the suggestion, @jqnatividad. Indeed, this would be useful. I'm wondering why I haven't thought about this. I will add this feature in the next release.

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index a1811aa..fd3b23e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,17 +25,17 @@ documentation = "https://docs.rs/grex"
 license = "Apache-2.0"
 readme = "README.md"
 edition = "2018"
-categories = ["command-line-utilities"]
+categories = ["command-line-utilities", "parsing"]
 keywords = ["pattern", "regex", "regexp"]
 
 [dependencies]
-atty = "0.2.14"
+atty = { version = "0.2.14", optional = true }
 itertools = "0.10.3"
 lazy_static = "1.4.0"
 ndarray = "0.15.4"
 petgraph = {version = "0.6.0", default-features = false, features = ["stable_graph"]}
 regex = "1.5.5"
-structopt = "0.3.26"
+structopt = { version = "0.3.26", optional = true }
 unic-char-range = "0.9.0"
 unic-ucd-category = "0.9.0"
 unicode-segmentation = "1.9.0"
@@ -47,3 +47,7 @@ predicates = "2.1.1"
 proptest = "1.0.0"
 rstest = "0.12.0"
 tempfile = "3.3.0"
+
+[features]
+default = ["cli"]
+cli = ["atty", "structopt"]
diff --git a/README.md b/README.md
index 1b52485..0e27852 100644
--- a/README.md
+++ b/README.md
@@ -123,7 +123,7 @@ In order to use *grex* as a library, simply add it as a dependency to your `Carg
 
 ```toml
 [dependencies]
-grex = "1.3.0"
+grex = { version = "1.3.0", default-features = false }
 ```
 
 ## 5. <a name="how-to-use"></a> How to use? <sup>[Top ▲](#table-of-contents)</sup>


Test patch: