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

Allow @Options with tuple types #691

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Allow @Options with tuple types #691

wants to merge 6 commits into from

Conversation

natecook1000
Copy link
Member

This adds @Option initializers that use variadic generics to work with tuples of any size.

From the symbol documentation:

For example, you could use this property wrapper to capture the three dimensions for a package:

struct Package: ParsableArguments {
    @Option
    var dimensions: (Double, Double, Double)
}

A user would then specify the three dimensions after the --dimensions key:

$ package --dimensions 5 4 12

Still to do

  • Decide on naming/etc on the help screen
  • Include in the serialized help info
  • Include in completion scripts
  • Document in guides

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

@natecook1000 natecook1000 requested a review from rauhul January 22, 2025 18:24
var index: Int
}

/// Returns a variadic tuple, with values generated by zipping the provided
Copy link
Contributor

Choose a reason for hiding this comment

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

variadic generic code is damn near impossible to read...

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.

2 participants