Skip to content

Commit 3551b7e

Browse files
authored
refactor(base): rename Experimental to Configure (#1438)
For some commands we might want to do more than just mark them as experimental, e.g. change their generated description. This PR renames `Experimental` to `Configure` to make it clear that the function can be used to configure all aspects of the command, not only to mark it as experimental.
1 parent 1b9288f commit 3551b7e

8 files changed

Lines changed: 34 additions & 34 deletions

File tree

internal/cmd/base/change_protection.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ type ChangeProtectionCmds[T, Opts any] struct {
5353
// IDOrName is used to retrieve a string representation of the resource
5454
IDOrName func(resource T) string
5555

56-
// Experimental is a function that will be used to mark the command as experimental.
57-
Experimental func(state.State, *cobra.Command) *cobra.Command
56+
// Configure is a function that can be used to configure the command directly.
57+
Configure func(state.State, *cobra.Command) *cobra.Command
5858
}
5959

6060
func (cpc *ChangeProtectionCmds[T, Opts]) newChangeProtectionCmd(s state.State, enable bool) *cobra.Command {
@@ -133,8 +133,8 @@ func (cpc *ChangeProtectionCmds[T, Opts]) newChangeProtectionCmd(s state.State,
133133
cpc.AdditionalFlags(cmd)
134134
}
135135

136-
if cpc.Experimental != nil {
137-
cmd = cpc.Experimental(s, cmd)
136+
if cpc.Configure != nil {
137+
cmd = cpc.Configure(s, cmd)
138138
}
139139

140140
return cmd

internal/cmd/base/create.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ type CreateCmd[T any] struct {
1919
// It should return the created resource, the schema of the resource and an error.
2020
Run func(state.State, *cobra.Command, []string) (T, any, error)
2121
PrintResource func(state.State, *cobra.Command, T)
22-
// Experimental is a function that will be used to mark the command as experimental.
23-
Experimental func(state.State, *cobra.Command) *cobra.Command
22+
// Configure is a function that can be used to configure the command directly.
23+
Configure func(state.State, *cobra.Command) *cobra.Command
2424
}
2525

2626
// CobraCommand creates a command that can be registered with cobra.
@@ -78,8 +78,8 @@ func (cc *CreateCmd[T]) CobraCommand(s state.State) *cobra.Command {
7878
return nil
7979
}
8080

81-
if cc.Experimental != nil {
82-
cmd = cc.Experimental(s, cmd)
81+
if cc.Configure != nil {
82+
cmd = cc.Configure(s, cmd)
8383
}
8484
return cmd
8585
}

internal/cmd/base/delete.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ type DeleteCmd[T any] struct {
4444
// [DeleteCmd.FetchWithArgs] and [DeleteCmd.PositionalArgumentOverride] is being used.
4545
ValidArgsFunction func(client hcapi2.Client) []cobra.CompletionFunc
4646

47-
// Experimental is a function that will be used to mark the command as experimental.
48-
Experimental func(state.State, *cobra.Command) *cobra.Command
47+
// Configure is a function that can be used to configure the command directly.
48+
Configure func(state.State, *cobra.Command) *cobra.Command
4949
}
5050

5151
type FetchFunc[T any] func(s state.State, cmd *cobra.Command, idOrName string) (T, *hcloud.Response, error)
@@ -84,8 +84,8 @@ func (dc *DeleteCmd[T]) CobraCommand(s state.State) *cobra.Command {
8484
if dc.AdditionalFlags != nil {
8585
dc.AdditionalFlags(cmd)
8686
}
87-
if dc.Experimental != nil {
88-
cmd = dc.Experimental(s, cmd)
87+
if dc.Configure != nil {
88+
cmd = dc.Configure(s, cmd)
8989
}
9090
return cmd
9191
}

internal/cmd/base/describe.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ type DescribeCmd[T any] struct {
4747
// [DescribeCmd.FetchWithArgs] and [DescribeCmd.PositionalArgumentOverride] is being used.
4848
ValidArgsFunction func(client hcapi2.Client) []cobra.CompletionFunc
4949

50-
// Experimental is a function that will be used to mark the command as experimental.
51-
Experimental func(state.State, *cobra.Command) *cobra.Command
50+
// Configure is a function that can be used to configure the command directly.
51+
Configure func(state.State, *cobra.Command) *cobra.Command
5252
}
5353

5454
// CobraCommand creates a command that can be registered with cobra.
@@ -84,8 +84,8 @@ func (dc *DescribeCmd[T]) CobraCommand(s state.State) *cobra.Command {
8484
dc.AdditionalFlags(cmd)
8585
}
8686

87-
if dc.Experimental != nil {
88-
cmd = dc.Experimental(s, cmd)
87+
if dc.Configure != nil {
88+
cmd = dc.Configure(s, cmd)
8989
}
9090

9191
return cmd

internal/cmd/base/labels.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ type LabelCmds[T any] struct {
4646
// provided as part of the [LabelCmds.ValidArgsFunction].
4747
ValidArgsFunction func(client hcapi2.Client) []cobra.CompletionFunc
4848

49-
// Experimental is a function that will be used to mark the command as experimental.
50-
Experimental func(state.State, *cobra.Command) *cobra.Command
49+
// Configure is a function that can be used to configure the command directly.
50+
Configure func(state.State, *cobra.Command) *cobra.Command
5151
}
5252

5353
// AddCobraCommand creates a command that can be registered with cobra.
@@ -79,8 +79,8 @@ func (lc *LabelCmds[T]) AddCobraCommand(s state.State) *cobra.Command {
7979

8080
cmd.Flags().BoolP("overwrite", "o", false, "Overwrite label if it exists already (true, false)")
8181

82-
if lc.Experimental != nil {
83-
cmd = lc.Experimental(s, cmd)
82+
if lc.Configure != nil {
83+
cmd = lc.Configure(s, cmd)
8484
}
8585

8686
return cmd
@@ -177,8 +177,8 @@ func (lc *LabelCmds[T]) RemoveCobraCommand(s state.State) *cobra.Command {
177177

178178
cmd.Flags().BoolP("all", "a", false, "Remove all labels")
179179

180-
if lc.Experimental != nil {
181-
cmd = lc.Experimental(s, cmd)
180+
if lc.Configure != nil {
181+
cmd = lc.Configure(s, cmd)
182182
}
183183

184184
return cmd

internal/cmd/base/list.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ type ListCmd[T any, S any] struct {
5656
// Can be set if auto-completion is needed (usually if [ListCmd.FetchWithArgs] is used)
5757
ValidArgsFunction func(client hcapi2.Client) cobra.CompletionFunc
5858

59-
// Experimental is a function that will be used to mark the command as experimental.
60-
Experimental func(state.State, *cobra.Command) *cobra.Command
59+
// Configure is a function that can be used to configure the command directly.
60+
Configure func(state.State, *cobra.Command) *cobra.Command
6161
}
6262

6363
// CobraCommand creates a command that can be registered with cobra.
@@ -92,8 +92,8 @@ func (lc *ListCmd[T, S]) CobraCommand(s state.State) *cobra.Command {
9292
lc.AdditionalFlags(cmd)
9393
}
9494
cmd.Flags().StringSliceP("sort", "s", []string{}, "Determine the sorting of the result")
95-
if lc.Experimental != nil {
96-
cmd = lc.Experimental(s, cmd)
95+
if lc.Configure != nil {
96+
cmd = lc.Configure(s, cmd)
9797
}
9898
return cmd
9999
}

internal/cmd/base/set_rdns.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ type SetRdnsCmd[T hcloud.RDNSSupporter] struct {
2222
Fetch func(s state.State, cmd *cobra.Command, idOrName string) (T, *hcloud.Response, error)
2323
GetDefaultIP func(resource T) net.IP
2424

25-
// Experimental is a function that will be used to mark the command as experimental.
26-
Experimental func(state.State, *cobra.Command) *cobra.Command
25+
// Configure is a function that can be used to configure the command directly.
26+
Configure func(state.State, *cobra.Command) *cobra.Command
2727
}
2828

2929
// CobraCommand creates a command that can be registered with cobra.
@@ -45,8 +45,8 @@ func (rc *SetRdnsCmd[T]) CobraCommand(s state.State) *cobra.Command {
4545

4646
cmd.Flags().IPP("ip", "i", net.IP{}, "IP address for which the reverse DNS entry should be set")
4747

48-
if rc.Experimental != nil {
49-
cmd = rc.Experimental(s, cmd)
48+
if rc.Configure != nil {
49+
cmd = rc.Configure(s, cmd)
5050
}
5151
return cmd
5252
}

internal/cmd/base/update.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ type UpdateCmd[T any] struct {
4141
// [UpdateCmd.FetchWithArgs] and [UpdateCmd.PositionalArgumentOverride] is being used.
4242
ValidArgsFunction func(client hcapi2.Client) []cobra.CompletionFunc
4343

44-
// Experimental is a function that will be used to mark the command as experimental.
45-
Experimental func(state.State, *cobra.Command) *cobra.Command
44+
// Configure is a function that can be used to configure the command directly.
45+
Configure func(state.State, *cobra.Command) *cobra.Command
4646
}
4747

4848
// CobraCommand creates a command that can be registered with cobra.
@@ -72,8 +72,8 @@ func (uc *UpdateCmd[T]) CobraCommand(s state.State) *cobra.Command {
7272
},
7373
}
7474
uc.DefineFlags(cmd)
75-
if uc.Experimental != nil {
76-
cmd = uc.Experimental(s, cmd)
75+
if uc.Configure != nil {
76+
cmd = uc.Configure(s, cmd)
7777
}
7878
return cmd
7979
}

0 commit comments

Comments
 (0)