nomino/config.go

34 lines
752 B
Go

package nomino
// Config controls how the generatred filename is created.
type Config struct {
original string
prefix string
suffix string
extension string
separator string
generator Generator
}
// NewConfig returns a new [Config] with the specified [Option]s.
// With no Options, the Config uses an extension of .txt, a separator
// of _, and the [UUID] [Generator].
func NewConfig(options ...Option) Config {
conf := Config{
extension: ".txt",
separator: "_",
generator: UUID(nil),
}
for _, opt := range options {
opt(&conf)
}
return conf
}
// AddOptions creates a new [Config] with the given [Option]s added.
func (c Config) AddOptions(options ...Option) Config {
for _, opt := range options {
opt(&c)
}
return c
}