nomino/config.go
2025-03-31 15:46:48 -05:00

34 lines
746 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 each [Option] specified.
// 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 each [Option] added.
func (c Config) AddOptions(options ...Option) Config {
for _, opt := range options {
opt(&c)
}
return c
}