package nomino import ( "strings" "github.com/gosimple/slug" ) // Option sets configuration parameters for Config. type Option func(c *Config) // WithOriginal sets the original filename. // This will be included in the generated name after the generated string and before the suffix. func WithOriginal(o string) Option { return func(c *Config) { c.original = o } } // WithOriginal sets the original filename as a slug. // This should not be used with the Slug Generator (as it would be redundant). func WithOriginalSlug(o string) Option { return func(c *Config) { c.original = slug.Make(o) } } // WithOriginal sets the original filename as a slug, taking the language into account. // This should not be used with the Slug Generator (as it would be redundant). func WithOriginalSlugLang(o, lang string) Option { return func(c *Config) { c.original = slug.MakeLang(o, lang) } } // WithPrefix sets a prefix for the generated name. func WithPrefix(p string) Option { return func(c *Config) { c.prefix = p } } // WithSuffix sets a suffix for the generated name. It will be included in the base name before the suffix. func WithSuffix(s string) Option { return func(c *Config) { c.suffix = s } } // WithoutExtension sets no extension for the generated filename. By default, it will be txt. func WithoutExtension() Option { return func(c *Config) { c.extension = "" } } // WithExtension sets the extension for the generated filename. func WithExtension(ext string) Option { return func(c *Config) { c.extension = "." + strings.TrimPrefix(ext, ".") } } // WithSeparator sets the separator for the generated filename. func WithSeparator(sep string) Option { return func(c *Config) { c.separator = sep } }