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

Check for group of repeated arguments #5488

Open
2 tasks done
Velnbur opened this issue May 8, 2024 · 0 comments
Open
2 tasks done

Check for group of repeated arguments #5488

Velnbur opened this issue May 8, 2024 · 0 comments
Labels
C-enhancement Category: Raise on the bar on expectations

Comments

@Velnbur
Copy link

Velnbur commented May 8, 2024

Please complete the following tasks

Clap Version

4.3.23

Describe your use case

Currently trying to implement a CLI that accepts different repeated arguments. The problem is that we need to add checks that the lengths of a subset of repeated parameters should be the same.

  1. So for example CLI sends different messages to different recipients:
# is okay
cli send --recipient ALICE --content "hi!" --recipient BOB --content "goodbye"
# results in error as no second recipient is presented
cli send --recipient ALICE --content "hi!" --content "goodbye"
  1. But recipients.len() < contents.len() is okay:
cli send --recipient ALICE --recipient BOB --content "hi!"

Just the same content will be sent to different recipients. So contents became vec!["hi!"; recipients.len()] in this case.

Describe the solution you'd like

Developing additional functionality to ArgGroup could fix that, but I have no context about its current implementation.

Alternatives, if applicable

I believe that #1704 will fix the first case of the requested feature. Which, with some additional tweaks, can fulfill my needs with second case too

Additional Context

No response

@Velnbur Velnbur added the C-enhancement Category: Raise on the bar on expectations label May 8, 2024
@Velnbur Velnbur changed the title Check for validation for group of repeated arguments Check for group of repeated arguments May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

1 participant