Skip to content

Commit 8848cfb

Browse files
committed
Put CLI deps behind a cli feature
1 parent 8370243 commit 8848cfb

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

.github/workflows/test.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
schedule:
77
- cron: '0 12 * * *'
88

9+
defaults:
10+
run:
11+
shell: bash
12+
913
jobs:
1014
test:
1115
runs-on: ${{ matrix.os }}
@@ -63,7 +67,12 @@ jobs:
6367
run: cargo build --verbose
6468

6569
- name: Test crate
66-
run: cargo hack --optional-deps --feature-powerset test --verbose
70+
run: |
71+
cargo hack \
72+
--optional-deps \
73+
--feature-powerset \
74+
--exclude-features default \
75+
test --verbose
6776
6877
coverage:
6978
# This is separate from the main tests because cargo-llvm-cov doesn't run
@@ -120,8 +129,13 @@ jobs:
120129
- name: Install cargo-hack
121130
uses: taiki-e/install-action@cargo-hack
122131

123-
- name: Check code
124-
run: cargo hack --optional-deps --feature-powerset clippy --all-targets -- -Dwarnings
132+
- name: Test crate
133+
run: |
134+
cargo hack \
135+
--optional-deps \
136+
--feature-powerset \
137+
--exclude-features default \
138+
clippy --all-targets -- -Dwarnings
125139
126140
- name: Check formatting
127141
run: cargo fmt --check

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ v0.5.0 (in development)
22
-----------------------
33
- Increased MSRV to 1.65
44
- Convert error Displays to lowercase per Rust conventions
5+
- The packages needed soley for the CLI are now behind a default `cli` feature
56

67
v0.4.0 (2023-02-15)
78
-------------------

Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ categories = ["command-line-utilities"]
1212
exclude = ["/.*"]
1313

1414
[dependencies]
15-
lexopt = "0.3.0"
15+
lexopt = { version = "0.3.0", optional = true }
1616
serde = { version = "1.0.160", optional = true }
1717

1818
[dev-dependencies]
@@ -24,6 +24,14 @@ serde_json = "1.0.96"
2424
tempfile = "3.5.0"
2525
which = "4.4.0"
2626

27+
[features]
28+
default = ["cli"]
29+
cli = ["dep:lexopt"]
30+
31+
[[bin]]
32+
name = "ghrepo"
33+
required-features = ["cli"]
34+
2735
[package.metadata.docs.rs]
2836
all-features = true
2937
rustdoc-args = ["--cfg", "docsrs"]

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ in your Cargo project, add the following to your `Cargo.toml`:
2323

2424
```toml
2525
[dependencies]
26-
ghrepo = "0.4.0"
26+
# By default, ghrepo depends on some packages only needed for its command-line
27+
# interface; disable the default features so that these dependencies aren't
28+
# pulled in when using as a library.
29+
ghrepo = { version = "0.4.0", default-features = false }
2730
```
2831

2932
To use `ghrepo` with its `serde` feature, add the following instead:
3033

3134
```toml
3235
[dependencies]
33-
ghrepo = { version = "0.4.0", features = ["serde"] }
36+
ghrepo = { version = "0.4.0", default-features = false, features = ["serde"] }
3437
```
3538

3639
To install the `ghrepo` command on your system, use `cargo install`:

tests/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "cli")]
12
// Use "pub" to silence some "unused code" warnings
23
pub mod repomaker;
34

0 commit comments

Comments
 (0)