Files
go-jdenticon/cmd/jdenticon/types.go
Kevin McIntyre d9e84812ff Initial release: Go Jdenticon library v0.1.0
- 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
2026-01-03 23:41:48 -05:00

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"
}