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

Mark flag as required if another flag is present, but not inversely so #2205

Open
notthelewis opened this issue Dec 13, 2024 · 0 comments
Open

Comments

@notthelewis
Copy link

notthelewis commented Dec 13, 2024

Just want to start off by commending the project as a whole. Very nice library, have started using it for a tool I'm building and I'm already looking at replacing previous solutions I have in other projects.

As per the title, I'd like to know if there's a way to make flags RequiredTogether but only in one direction. For example, I'm reading in config something like this:

# Edit config for specific service
./tool edit -s "customerService" 

# Edit config for test on service
./tool edit -s "customerService" -t "shouldReturnTrue" 

And what I wanted to do was make it so that the -s flag can be used on it's own in isolation, but the -t flag cannot, as it depends on the -s flag.

My gut reaction was something like this:

EditCmd.MarkFlagsRequiredTogether("testName", "serviceName")

But of course, this works in both directions (i.e. service name also would require test name).

Is there any way around this?

@notthelewis notthelewis changed the title Mark flag as required if another flag is present Mark flag as required if another flag is present, but not inversely so Dec 13, 2024
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

No branches or pull requests

1 participant