2025-03-10 14:52:50 -05:00
|
|
|
package nomino
|
|
|
|
|
|
2025-03-31 12:10:05 -05:00
|
|
|
// 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.
|
2025-03-31 12:10:05 -05:00
|
|
|
// 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: "_",
|
2025-03-16 12:38:36 -05:00
|
|
|
generator: UUID(nil),
|
2025-03-10 14:52:50 -05:00
|
|
|
}
|
|
|
|
|
for _, opt := range options {
|
|
|
|
|
opt(&conf)
|
|
|
|
|
}
|
|
|
|
|
return conf
|
|
|
|
|
}
|
2025-03-18 09:22:30 -05:00
|
|
|
|
2025-03-31 15:46:48 -05:00
|
|
|
// AddOptions creates a new [Config] with each [Option] added.
|
2025-03-18 09:22:30 -05:00
|
|
|
func (c Config) AddOptions(options ...Option) Config {
|
|
|
|
|
for _, opt := range options {
|
|
|
|
|
opt(&c)
|
|
|
|
|
}
|
|
|
|
|
return c
|
|
|
|
|
}
|