searcherside/internal/flags/hex_string.go

28 lines
386 B
Go

package flags
import (
"encoding/hex"
"github.com/alecthomas/kong"
)
type HexString []byte
func (h *HexString) Raw() []byte {
return *h
}
func (h *HexString) Decode(ctx *kong.DecodeContext) error {
token, err := ctx.Scan.PopValue("hex")
if err != nil {
return err
}
data, err := hex.DecodeString(token.String())
if err != nil {
return err
}
*h = data
return nil
}