Skip to content

Conversation

@bok-
Copy link
Contributor

@bok- bok- commented Oct 21, 2025

📒 Description

This PR makes two changes to simplify and align the @Flag and @FlagGroup macros:

@Flag

It removes the default: parameter from the @Flag macro. This aligns with how swift-argument-parser does their default value specification, but more importantly removes this foot-gun:

@Flag(default: .enumCase, description: "...")           // error: Cannot infer type of `.enumCase`
var someFlag: SomeEnum

This is because the macro generic on the macro cannot be inferred from the property it is attached to, it must be self contained. Removing this overload makes adoption easier.

@FlagGroup

A simplified overload for @FlagGroup has been added to align with @Flag:

@FlagGroup("Description")
var someFlagGroup: SomeFlagGroup

@FlagGroup("Description", display: .section)
var otherFlagGroup: OtherFlagGroup

The description: parameter label is now only required if you are also specifying the name: and/or keyStrategy: parameters.

🗳 Test Plan

This is fully covered by unit tests and macro tests.

🧯 Source Impact

Breaking change but this is part of the Vexil 3 alpha.

✅ 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

@bok- bok- added patch A tiny change according to semver. vexil3 Part of the Vexil 3 alpha/beta development labels Oct 21, 2025
@bok- bok- force-pushed the macro-alignment branch 2 times, most recently from f4c790b to fa2abe1 Compare October 21, 2025 11:47
@sonarqubecloud
Copy link

@bok- bok- merged commit 49bc404 into main Oct 21, 2025
60 of 66 checks passed
@bok- bok- deleted the macro-alignment branch October 21, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A tiny change according to semver. vexil3 Part of the Vexil 3 alpha/beta development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants