💡 Document code
This commit is contained in:
parent
1af608d7c9
commit
abe7acffd4
2 changed files with 18 additions and 0 deletions
|
|
@ -17,32 +17,39 @@ func defaultConf() config {
|
|||
}
|
||||
}
|
||||
|
||||
// Option is an option for nomino
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
// 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, ".")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue