nomino/config.go

35 lines
746 B
Go
Raw Normal View History

2025-03-10 14:52:50 -05:00
package nomino
// Config controls how the generatred filename is created.
2025-03-10 14:52:50 -05:00
type Config struct {
original string
prefix string
suffix string
extension string
2025-03-11 16:42:39 -05:00
separator string
2025-03-10 14:52:50 -05:00
generator Generator
}
2025-03-31 15:46:48 -05:00
// 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].
2025-03-10 14:52:50 -05:00
func NewConfig(options ...Option) Config {
conf := Config{
extension: ".txt",
2025-03-11 16:42:39 -05:00
separator: "_",
generator: UUID(nil),
2025-03-10 14:52:50 -05:00
}
for _, opt := range options {
opt(&conf)
}
return conf
}
2025-03-31 15:46:48 -05:00
// AddOptions creates a new [Config] with each [Option] added.
func (c Config) AddOptions(options ...Option) Config {
for _, opt := range options {
opt(&c)
}
return c
}