Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow passing non-default features #48

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

balins
Copy link
Contributor

@balins balins commented Jan 24, 2025

This PR allows for passing additional features for the package (either space or comma-separated, multiple occurrences of --features [...] are allowed). This allows us to pull licenses for optional dependencies. Notice that the default features are always enabled.

If at least one non-existing feature is provided, the CLI will exit with an error message:

cargo bundle-licenses --features somefeature,nonexistent --output THIRDPARTY.toml
Error: `cargo metadata` exited with an error: error: the package 'package' does not contain this feature: nonexistent

Similarly, passing empty feature list will error out as well:

cargo bundle-licenses --features --output THIRDPARTY.toml
error: The argument '--features <features>...' requires a value but none was supplied

USAGE:
    cargo bundle-licenses --features <features>... --format <format> --output <output>

For more information try --help

(I guess this is desirable behavior to catch interpolating empty values in scripts etc.)

While this isn't a breaking change for the CLI itself (default features are preserved and the new option is, well, optional), this is a breaking change for the cargo-bundle-licenses as a library. If this is an issue, we can consider preserving the old API and creating separate methods / structs that the old API will proxy to.

Fixes #47

@balins balins changed the title feat: allow to pass non-default features feat: allow passing non-default features Jan 24, 2025
@sstadick
Copy link
Owner

@balins this is great! I'll get it merged in and released tomorrow morning.

RE backward compat for using this as a library, I don't think anyone uses this that way, but to be on the safe side we'll make this a major version bump.

@sstadick sstadick merged commit f1d0aa0 into sstadick:main Jan 27, 2025
4 checks passed
@sstadick
Copy link
Owner

This should be in the 3.0.0 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing licenses for optional dependencies
2 participants