- Core library with SVG and PNG generation - CLI tool with generate and batch commands - Cross-platform path handling for Windows compatibility - Comprehensive test suite with integration tests
36 lines
792 B
Go
36 lines
792 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
// FormatFlag is a custom pflag.Value for handling --format validation and completion
|
|
type FormatFlag string
|
|
|
|
const (
|
|
// FormatPNG represents PNG output format for identicon generation
|
|
FormatPNG FormatFlag = "png"
|
|
|
|
// FormatSVG represents SVG output format for identicon generation
|
|
FormatSVG FormatFlag = "svg"
|
|
)
|
|
|
|
// String is used both by pflag and fmt.Stringer
|
|
func (f *FormatFlag) String() string {
|
|
return string(*f)
|
|
}
|
|
|
|
// Set must have pointer receiver, so it can change the value of f.
|
|
func (f *FormatFlag) Set(v string) error {
|
|
switch v {
|
|
case "png", "svg":
|
|
*f = FormatFlag(v)
|
|
return nil
|
|
default:
|
|
return fmt.Errorf(`must be one of "png" or "svg"`)
|
|
}
|
|
}
|
|
|
|
// Type is only used in help text
|
|
func (f *FormatFlag) Type() string {
|
|
return "string"
|
|
}
|