@@ -16,17 +16,17 @@ type JSONConfig struct {
1616 SetValue interface {}
1717}
1818
19- type JsonValueCreator [T any ] struct {}
19+ type JSONValueCreator [T any ] struct {}
2020
21- func (c JsonValueCreator [T ]) Create (val T , dest * T , config JSONConfig ) cli.Value {
21+ func (c JSONValueCreator [T ]) Create (val T , dest * T , config JSONConfig ) cli.Value {
2222 * dest = val
2323 return & jsonValue [T ]{
2424 destination : dest ,
2525 config : config ,
2626 }
2727}
2828
29- func (c JsonValueCreator [T ]) ToString (val T ) string {
29+ func (c JSONValueCreator [T ]) ToString (val T ) string {
3030 switch v := any (val ).(type ) {
3131 case string :
3232 if v == "" {
@@ -59,13 +59,13 @@ func (v *jsonValue[T]) Set(val string) error {
5959 if v .config .SetValue != nil {
6060 // For boolean flags with SetValue, register the configured value
6161 if _ , isBool := any (parsed ).(bool ); isBool {
62- globalRegistry .Register (v .config .Kind , v .config .Path , v .config .SetValue )
62+ globalRegistry .Mutate (v .config .Kind , v .config .Path , v .config .SetValue )
6363 * v .destination = any (true ).(T ) // Set the flag itself to true
6464 return nil
6565 }
6666 // For any flags with SetValue, register the configured value
6767 if _ , isAny := any (parsed ).(interface {}); isAny {
68- globalRegistry .Register (v .config .Kind , v .config .Path , v .config .SetValue )
68+ globalRegistry .Mutate (v .config .Kind , v .config .Path , v .config .SetValue )
6969 * v .destination = any (v .config .SetValue ).(T )
7070 return nil
7171 }
@@ -123,7 +123,7 @@ func (v *jsonValue[T]) Set(val string) error {
123123 }
124124
125125 * v .destination = parsed
126- globalRegistry .Register (v .config .Kind , v .config .Path , parsed )
126+ globalRegistry .Mutate (v .config .Kind , v .config .Path , parsed )
127127 return err
128128}
129129
@@ -173,18 +173,18 @@ func (v *jsonValue[T]) IsBoolFlag() bool {
173173 return v .config .SetValue != nil
174174}
175175
176- // JsonDateValueCreator is a specialized creator for date-only values
177- type JsonDateValueCreator struct {}
176+ // JSONDateValueCreator is a specialized creator for date-only values
177+ type JSONDateValueCreator struct {}
178178
179- func (c JsonDateValueCreator ) Create (val time.Time , dest * time.Time , config JSONConfig ) cli.Value {
179+ func (c JSONDateValueCreator ) Create (val time.Time , dest * time.Time , config JSONConfig ) cli.Value {
180180 * dest = val
181181 return & jsonDateValue {
182182 destination : dest ,
183183 config : config ,
184184 }
185185}
186186
187- func (c JsonDateValueCreator ) ToString (val time.Time ) string {
187+ func (c JSONDateValueCreator ) ToString (val time.Time ) string {
188188 return val .Format ("2006-01-02" )
189189}
190190
@@ -220,7 +220,7 @@ func (v *jsonDateValue) Set(val string) error {
220220 }
221221
222222 * v .destination = timeVal
223- globalRegistry .Register (v .config .Kind , v .config .Path , timeVal .Format ("2006-01-02" ))
223+ globalRegistry .Mutate (v .config .Kind , v .config .Path , timeVal .Format ("2006-01-02" ))
224224 return nil
225225}
226226
@@ -242,14 +242,6 @@ func (v *jsonDateValue) IsBoolFlag() bool {
242242 return false
243243}
244244
245- type JSONStringFlag = cli.FlagBase [string , JSONConfig , JsonValueCreator [string ]]
246- type JSONBoolFlag = cli.FlagBase [bool , JSONConfig , JsonValueCreator [bool ]]
247- type JSONIntFlag = cli.FlagBase [int , JSONConfig , JsonValueCreator [int ]]
248- type JSONFloatFlag = cli.FlagBase [float64 , JSONConfig , JsonValueCreator [float64 ]]
249- type JSONDatetimeFlag = cli.FlagBase [time.Time , JSONConfig , JsonValueCreator [time.Time ]]
250- type JSONDateFlag = cli.FlagBase [time.Time , JSONConfig , JsonDateValueCreator ]
251- type JSONAnyFlag = cli.FlagBase [interface {}, JSONConfig , JsonValueCreator [interface {}]]
252-
253245// JsonFileValueCreator handles file-based flags that read content and register with mutations
254246type JsonFileValueCreator struct {}
255247
@@ -281,7 +273,7 @@ func (v *jsonFileValue) Set(filePath string) error {
281273 * v .destination = filePath
282274
283275 // Register the file content with the global registry
284- globalRegistry .Register (v .config .Kind , v .config .Path , string (content ))
276+ globalRegistry .Mutate (v .config .Kind , v .config .Path , string (content ))
285277 return nil
286278}
287279
@@ -304,3 +296,10 @@ func (v *jsonFileValue) IsBoolFlag() bool {
304296}
305297
306298type JSONFileFlag = cli.FlagBase [string , JSONConfig , JsonFileValueCreator ]
299+ type JSONStringFlag = cli.FlagBase [string , JSONConfig , JSONValueCreator [string ]]
300+ type JSONBoolFlag = cli.FlagBase [bool , JSONConfig , JSONValueCreator [bool ]]
301+ type JSONIntFlag = cli.FlagBase [int , JSONConfig , JSONValueCreator [int ]]
302+ type JSONFloatFlag = cli.FlagBase [float64 , JSONConfig , JSONValueCreator [float64 ]]
303+ type JSONDatetimeFlag = cli.FlagBase [time.Time , JSONConfig , JSONValueCreator [time.Time ]]
304+ type JSONDateFlag = cli.FlagBase [time.Time , JSONConfig , JSONDateValueCreator ]
305+ type JSONAnyFlag = cli.FlagBase [interface {}, JSONConfig , JSONValueCreator [interface {}]]
0 commit comments