refactor: move install options to pkg/uixt/options/install

This commit is contained in:
lilong.129
2025-02-06 16:45:40 +08:00
parent 0accec04a9
commit b22f24cb6b
9 changed files with 58 additions and 55 deletions

View File

@@ -0,0 +1,42 @@
package options
type InstallOptions struct {
Reinstall bool
GrantPermission bool
Downgrade bool
RetryTimes int
}
type InstallOption func(o *InstallOptions)
func NewInstallOptions(opts ...InstallOption) *InstallOptions {
installOptions := &InstallOptions{}
for _, option := range opts {
option(installOptions)
}
return installOptions
}
func WithReinstall(reinstall bool) InstallOption {
return func(o *InstallOptions) {
o.Reinstall = reinstall
}
}
func WithGrantPermission(grantPermission bool) InstallOption {
return func(o *InstallOptions) {
o.GrantPermission = grantPermission
}
}
func WithDowngrade(downgrade bool) InstallOption {
return func(o *InstallOptions) {
o.Downgrade = downgrade
}
}
func WithRetryTimes(retryTimes int) InstallOption {
return func(o *InstallOptions) {
o.RetryTimes = retryTimes
}
}