Skip to content

feat: support the 'combinable' & 'only' flag relationships#1487

Merged
mdonnalley merged 1 commit intooclif:mdonnalley/1487from
thgreasi:exclusiveUnless-only-with
Oct 20, 2025
Merged

feat: support the 'combinable' & 'only' flag relationships#1487
mdonnalley merged 1 commit intooclif:mdonnalley/1487from
thgreasi:exclusiveUnless-only-with

Conversation

@thgreasi
Copy link
Contributor

@thgreasi thgreasi commented Oct 19, 2025

This new flag relationship aims to ease defining that a specific flag is ONLY compatible with just a few other ones.
Currently users would have to enumerate all other incompatible flags in the exclusive relationship, which leads to some repetition, doesn't capture exactly the original intention, and could lead to oversights if more flags are added to that command later. I realized this use case while working on a balena-cli PR, where we had to define that
--config is allowed to be combined with the --yes flag and is incompatible with all other flags.
The workaround that we ended up having to use, was to use an IIFE and define the compatible flags in a separate array and reference that in the exclusive property. balena-io/balena-cli@692e70d

I'm sure I have missed some pieces like adding proper docs, but thought it would be better to first check whether there would be interest in extending the flag relationships. For sure plz suggest any better name that you can think.

This new flag relationship aims to ease defining that a specific flag is ONLY compatible
with just a few other ones.
Currently users would have to enumerate all other incompatible flags in the exclusive relationship,
which leads to some repetition, doesn't capture exactly the original intention, and could lead to
oversights if more flags are added to that command later.
I realized this use case while working on a balena-cli PR, where we had to define that
 --config is allowed to be combined with the --yes flag and is incompatible with all other flags.
The workaround that we ended up having to use, was to use an IIFE and define the compatible flags
in a separate array and reference that in the exclusive property.
balena-io/balena-cli@692e70d
@mdonnalley mdonnalley added the enhancement New feature or request label Oct 20, 2025
@git2gus
Copy link

git2gus bot commented Oct 20, 2025

This issue has been linked to a new work item: W-19992287

@mdonnalley
Copy link
Contributor

@thgreasi Just tested this out and it works great! Thanks for making the change

I'll merge this into a separate feature branch so that integration tests can run. Once those pass, I'll merge to main

@mdonnalley mdonnalley changed the base branch from main to mdonnalley/1487 October 20, 2025 16:16
@mdonnalley mdonnalley merged commit aad267e into oclif:mdonnalley/1487 Oct 20, 2025
1 check passed
@thgreasi
Copy link
Contributor Author

Thanks for the instant review @mdonnalley 🙏
Let me know if I have missed anything that needs a follow-up.

@thgreasi thgreasi deleted the exclusiveUnless-only-with branch October 20, 2025 16:19
mdonnalley added a commit that referenced this pull request Oct 20, 2025
…1488)

This new flag relationship aims to ease defining that a specific flag is ONLY compatible
with just a few other ones.
Currently users would have to enumerate all other incompatible flags in the exclusive relationship,
which leads to some repetition, doesn't capture exactly the original intention, and could lead to
oversights if more flags are added to that command later.
I realized this use case while working on a balena-cli PR, where we had to define that
 --config is allowed to be combined with the --yes flag and is incompatible with all other flags.
The workaround that we ended up having to use, was to use an IIFE and define the compatible flags
in a separate array and reference that in the exclusive property.
balena-io/balena-cli@692e70d

Co-authored-by: Thodoris Greasidis <thgreasi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:signed enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants