Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 399ad8c

Browse files
author
Hendrik van Antwerpen
committed
Make CLI parts optional
1 parent 804ca1d commit 399ad8c

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

languages/tree-sitter-stack-graphs-typescript/Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ edition = "2018"
1111
[[bin]]
1212
name = "tree-sitter-stack-graphs-typescript"
1313
path = "rust/bin.rs"
14+
required-features = ["cli"]
1415

1516
[lib]
1617
path = "rust/lib.rs"
@@ -20,14 +21,19 @@ test = false
2021
name = "test"
2122
path = "rust/test.rs"
2223
harness = false
24+
required-features = ["tree-sitter-stack-graphs/cli"] # this should be *forced* for tests, but cargo does not support that
25+
26+
[features]
27+
default = ["cli"] # as long as the required features for test cannot be forced, we enable cli by default, to make sure tests are always run
28+
cli = ["anyhow", "clap", "tree-sitter-stack-graphs/cli"]
2329

2430
[dependencies]
25-
anyhow = "1.0"
26-
clap = "3"
31+
anyhow = { version = "1.0", optional = true }
32+
clap = { version = "3", optional = true }
2733
glob = "0.3"
2834
serde = { version = "1.0", features = ["derive"] }
2935
serde_json = "1.0"
3036
stack-graphs = { version = "0.10", path = "../../stack-graphs" }
31-
tree-sitter-stack-graphs = { version = "0.6", path = "../../tree-sitter-stack-graphs", features=["cli"] }
37+
tree-sitter-stack-graphs = { version = "0.6", path = "../../tree-sitter-stack-graphs" }
3238
tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev="082da44a5263599186dadafd2c974c19f3a73d28" }
3339
tsconfig = "0.1.0"

languages/tree-sitter-stack-graphs-typescript/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ extension for syntax highlighting.
7878
Parse and test a single file by executing the following commands:
7979

8080
``` sh
81-
$ cargo run -- parse FILES...
82-
$ cargo run -- test TESTFILES...
81+
$ cargo run --features cli -- parse FILES...
82+
$ cargo run --features cli -- test TESTFILES...
8383
```
8484

8585
Additional flags can be passed to these commands as well. For example, to generate
8686
a visualization for the test, execute:
8787

8888
``` sh
89-
$ cargo run -- test -V TESTFILES...
89+
$ cargo run --features cli -- test -V TESTFILES...
9090
```
9191

9292
To generate the visualization regardless of test outcome, execute:
9393

9494
``` sh
95-
$ cargo run -- test -V --output-mode=always TESTFILES...
95+
$ cargo run --features cli -- test -V --output-mode=always TESTFILES...
9696
```
9797

9898
Go to https://crates.io/crates/tree-sitter-stack-graphs for links to examples and documentation.

0 commit comments

Comments
 (0)