mage/release/option.go

68 lines
1.2 KiB
Go
Raw Normal View History

2019-08-02 16:21:29 +02:00
package release
type Options struct {
Systems []OS
Archs []Arch
DefaultArchiveType string
ArchiveTypeMap map[OS]string
BaseDir string
ProjectName string
Env map[string]string
}
type OptionFunc func(*Options)
func WithEnv(env map[string]string) OptionFunc {
return func(opts *Options) {
opts.Env = env
}
}
func WithSystems(systems ...OS) OptionFunc {
return func(opts *Options) {
opts.Systems = systems
}
}
func WithArchs(archs ...Arch) OptionFunc {
return func(opts *Options) {
opts.Archs = archs
}
}
func WithProjectName(projectName string) OptionFunc {
return func(opts *Options) {
opts.ProjectName = projectName
}
}
func WithBaseDir(baseDir string) OptionFunc {
return func(opts *Options) {
opts.BaseDir = baseDir
}
}
func defaultOptions() *Options {
return &Options{
Systems: []OS{
OSLinux,
OSWindows,
OSDarwin,
},
Archs: []Arch{
Arch386,
ArchAMD64,
ArchARM,
},
DefaultArchiveType: "tar.gz",
ArchiveTypeMap: map[OS]string{
OSWindows: "zip",
OSLinux: "tar.gz",
OSDarwin: "zip",
},
BaseDir: "release",
ProjectName: "my-project",
Env: make(map[string]string),
}
}