Skip to content

Gate CLI dependencies behind optional cli feature flag#848

Merged
benfred merged 1 commit intobenfred:masterfrom
grafana:kk/cli-gate
May 4, 2026
Merged

Gate CLI dependencies behind optional cli feature flag#848
benfred merged 1 commit intobenfred:masterfrom
grafana:kk/cli-gate

Conversation

@korniltsev-grafanista
Copy link
Copy Markdown
Contributor

py-spy is used as a library in pyroscope-rs where CLI dependencies
(clap, inferno, console, ctrlc, indicatif, env_logger) are unnecessary.
This adds a cli feature flag (enabled by default) that guards all
CLI-only dependencies, allowing library consumers to opt out with
default-features = false.

Changes:

  • Make clap, clap_complete, console, ctrlc, indicatif, inferno, and
    env_logger optional dependencies gated by the cli feature
  • Add [[bin]] with required-features = ["cli"] so the binary is
    skipped when building without CLI
  • Gate clap-dependent code in config.rs (ArgEnum derive, from_commandline,
    from_args, CLI tests) behind cli feature
  • Add CI step to build library without cli feature
  • Gate coredump and dump modiles behind cli feature

py-spy is used as a library in pyroscope-rs where CLI dependencies
(clap, inferno, console, ctrlc, indicatif, env_logger) are unnecessary.
This adds a `cli` feature flag (enabled by default) that guards all
CLI-only dependencies, allowing library consumers to opt out with
`default-features = false`.

Changes:
- Make clap, clap_complete, console, ctrlc, indicatif, inferno, and
  env_logger optional dependencies gated by the `cli` feature
- Add `[[bin]]` with `required-features = ["cli"]` so the binary is
  skipped when building without CLI
- Gate clap-dependent code in config.rs (ArgEnum derive, from_commandline,
  from_args, CLI tests) behind cli feature
- Add CI step to build library without cli feature
- Gate coredump and dump modiles behind cli feature
@benfred benfred added the enhancement New feature or request label May 4, 2026
Copy link
Copy Markdown
Owner

@benfred benfred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR!

This does make me wonder if the dump/coredump code should even be exported from src/lib.rs at all - but I think we can leave as is for now

@benfred benfred merged commit 194bf64 into benfred:master May 4, 2026
110 checks passed
@korniltsev-grafanista
Copy link
Copy Markdown
Contributor Author

@benfred Thanks for prompt review 🙏 💘
Any chance to publish a new version of the crate for downstream library users?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants