@@ -57,10 +57,10 @@ struct MyFlags: FlagContainer {
5757@FlagContainer
5858struct MyFlags {
5959
60- @Flag (default : false , description : " Test flag that does something magical" )
61- var testFlag: Bool
60+ @Flag (" Test flag that does something magical" )
61+ var testFlag = false
6262
63- @FlagGroup (description : " Some nested flags" )
63+ @FlagGroup (" Some nested flags" )
6464 var nested: NestedFlags
6565
6666}
@@ -117,12 +117,19 @@ FlagContainer.init(
117117Under Vexil 3, this is now a macro:
118118
119119``` swift
120+ // Full macro
120121public macro FlagGroup (
121122 name : StaticString ? = nil ,
122123 keyStrategy : VexilConfiguration.GroupKeyStrategy = .default ,
123124 description : StaticString ,
124125 display : VexilDisplayOption = .navigation
125126)
127+
128+ // Or shorter
129+ public macro FlagGroup (
130+ _ description : StaticString ,
131+ display : VexilDisplayOption = .navigation
132+ )
126133```
127134
128135As you can see the changes here purely for simplification: ` codingKeyStrategy `
@@ -136,14 +143,14 @@ could set your description to `.hidden`; now you pass `.hidden` to display:
136143var nested: NestedFlags
137144
138145// Vexil 3
139- @FlagGroup (description : " Nested flags" , display: .hidden )
146+ @FlagGroup (" Nested flags" , display: .hidden )
140147var nested: NestedFlags
141148```
142149
143150### Flags
144151
145152Much like Flag Groups, the ` @Flag ` property wrapper was replaced with the
146- `` Flag(name:keyStrategy:default: description:) `` macro, with simplified parameters:
153+ `` Flag(name:keyStrategy:description:display :) `` macro, with simplified parameters:
147154
148155``` swift
149156// Vexil 2
@@ -156,9 +163,6 @@ var magic = false
156163
157164// Vexil 3
158165
159- @Flag (default : false , description: " Flag that enables magic" )
160- var magic: Bool
161-
162166@Flag (" Flag that enables magic" )
163167var magic = false
164168```
@@ -184,18 +188,9 @@ init(
184188)
185189```
186190
187- Both approaches are available via the ` @Flag ` macro:
191+ With the ` @Flag ` macro we now require the property initialiser.
188192
189193``` swift
190- /// Explicit default parameter
191- macro Flag <Value : FlagValue >(
192- name : StaticString ? = nil ,
193- keyStrategy : VexilConfiguration.FlagKeyStrategy = .default ,
194- default initialValue : Value ,
195- description : StaticString ,
196- display : FlagDisplayOption = .default
197- )
198-
199194/// Sets default via property initialiser
200195macro Flag (
201196 name : StaticString ? = nil ,
@@ -211,6 +206,19 @@ macro Flag(_ description: StaticString)
211206Same as with the ` FlagGroup ` , the ` codingKeyStrategy ` parameter has been shortened
212207to ` keyStrategy ` , and the ability to hide flags has been moved to the ` display ` property.
213208
209+ > Note:
210+ >
211+ > The ` default: ` parameter option was removed as it included a large foot-gun with cryptic
212+ > error message. It was decided to remove this potential issue by aligning with
213+ > [ swift-argument-parser] ( https://github.com/apple/swift-argument-parser ) 's approach.
214+ >
215+ > As the macro is type-checked without reference to the attached property's type you get errors like:
216+ >
217+ > ``` swift
218+ > @Flag (default : .enumCase , description: " " ) // compiler error: Type of `.enumCase` cannot be inferred.
219+ > var myFlag: MyEnum
220+ > ```
221+
214222## Flag Pole Observation
215223
216224Under Vexil 2 , every time a `FlagValueSource` reported a flag value change, we would
0 commit comments