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
This commit is contained in:
35
cmd/jdenticon/types.go
Normal file
35
cmd/jdenticon/types.go
Normal file
@@ -0,0 +1,35 @@
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user