| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | package nomino | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import "strings" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-10 14:52:50 -05:00
										 |  |  | // Option sets configuration parameters for Config. | 
					
						
							|  |  |  | type Option func(c *Config) | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-10 13:46:13 -05:00
										 |  |  | // WithOriginal sets the original filename. | 
					
						
							|  |  |  | // This will be included in the generated name after the generated string and before the suffix. | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | func WithOriginal(o string) Option { | 
					
						
							| 
									
										
										
										
											2025-03-10 14:52:50 -05:00
										 |  |  | 	return func(c *Config) { | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | 		c.original = "_" + o | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-10 13:46:13 -05:00
										 |  |  | // WithPrefix sets a prefix for the generated name. | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | func WithPrefix(p string) Option { | 
					
						
							| 
									
										
										
										
											2025-03-10 14:52:50 -05:00
										 |  |  | 	return func(c *Config) { | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | 		c.prefix = p + "_" | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-10 13:46:13 -05:00
										 |  |  | // WithSuffix sets a suffix for the generated name. It will be included in the base name before the suffix. | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | func WithSuffix(s string) Option { | 
					
						
							| 
									
										
										
										
											2025-03-10 14:52:50 -05:00
										 |  |  | 	return func(c *Config) { | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | 		c.suffix = "_" + s | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-10 13:46:13 -05:00
										 |  |  | // WithoutExtension sets no extension for the generated filename. By default, it will be txt | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | func WithoutExtension() Option { | 
					
						
							| 
									
										
										
										
											2025-03-10 14:52:50 -05:00
										 |  |  | 	return func(c *Config) { | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | 		c.extension = "" | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-10 13:46:13 -05:00
										 |  |  | // WithExtension sets the extension for the generated filename. | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | func WithExtension(ext string) Option { | 
					
						
							| 
									
										
										
										
											2025-03-10 14:52:50 -05:00
										 |  |  | 	return func(c *Config) { | 
					
						
							| 
									
										
										
										
											2025-03-07 16:26:24 -06:00
										 |  |  | 		c.extension = "." + strings.TrimPrefix(ext, ".") | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |