package pflag

import (
	
	
	
	
)

// BytesHex adapts []byte for use as a flag. Value of flag is HEX encoded
type bytesHexValue []byte

// String implements pflag.Value.String.
func ( bytesHexValue) () string {
	return fmt.Sprintf("%X", []byte())
}

// Set implements pflag.Value.Set.
func ( *bytesHexValue) ( string) error {
	,  := hex.DecodeString(strings.TrimSpace())

	if  != nil {
		return 
	}

	* = 

	return nil
}

// Type implements pflag.Value.Type.
func (*bytesHexValue) () string {
	return "bytesHex"
}

func newBytesHexValue( []byte,  *[]byte) *bytesHexValue {
	* = 
	return (*bytesHexValue)()
}

func bytesHexConv( string) (interface{}, error) {

	,  := hex.DecodeString()

	if  == nil {
		return , nil
	}

	return nil, fmt.Errorf("invalid string being converted to Bytes: %s %s", , )
}

// GetBytesHex return the []byte value of a flag with the given name
func ( *FlagSet) ( string) ([]byte, error) {
	,  := .getFlagType(, "bytesHex", bytesHexConv)

	if  != nil {
		return []byte{}, 
	}

	return .([]byte), nil
}

// BytesHexVar defines an []byte flag with specified name, default value, and usage string.
// The argument p points to an []byte variable in which to store the value of the flag.
func ( *FlagSet) ( *[]byte,  string,  []byte,  string) {
	.VarP(newBytesHexValue(, ), , "", )
}

// BytesHexVarP is like BytesHexVar, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) ( *[]byte, ,  string,  []byte,  string) {
	.VarP(newBytesHexValue(, ), , , )
}

// BytesHexVar defines an []byte flag with specified name, default value, and usage string.
// The argument p points to an []byte variable in which to store the value of the flag.
func ( *[]byte,  string,  []byte,  string) {
	CommandLine.VarP(newBytesHexValue(, ), , "", )
}

// BytesHexVarP is like BytesHexVar, but accepts a shorthand letter that can be used after a single dash.
func ( *[]byte, ,  string,  []byte,  string) {
	CommandLine.VarP(newBytesHexValue(, ), , , )
}

// BytesHex defines an []byte flag with specified name, default value, and usage string.
// The return value is the address of an []byte variable that stores the value of the flag.
func ( *FlagSet) ( string,  []byte,  string) *[]byte {
	 := new([]byte)
	.BytesHexVarP(, , "", , )
	return 
}

// BytesHexP is like BytesHex, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) (,  string,  []byte,  string) *[]byte {
	 := new([]byte)
	.BytesHexVarP(, , , , )
	return 
}

// BytesHex defines an []byte flag with specified name, default value, and usage string.
// The return value is the address of an []byte variable that stores the value of the flag.
func ( string,  []byte,  string) *[]byte {
	return CommandLine.BytesHexP(, "", , )
}

// BytesHexP is like BytesHex, but accepts a shorthand letter that can be used after a single dash.
func (,  string,  []byte,  string) *[]byte {
	return CommandLine.BytesHexP(, , , )
}

// BytesBase64 adapts []byte for use as a flag. Value of flag is Base64 encoded
type bytesBase64Value []byte

// String implements pflag.Value.String.
func ( bytesBase64Value) () string {
	return base64.StdEncoding.EncodeToString([]byte())
}

// Set implements pflag.Value.Set.
func ( *bytesBase64Value) ( string) error {
	,  := base64.StdEncoding.DecodeString(strings.TrimSpace())

	if  != nil {
		return 
	}

	* = 

	return nil
}

// Type implements pflag.Value.Type.
func (*bytesBase64Value) () string {
	return "bytesBase64"
}

func newBytesBase64Value( []byte,  *[]byte) *bytesBase64Value {
	* = 
	return (*bytesBase64Value)()
}

func bytesBase64ValueConv( string) (interface{}, error) {

	,  := base64.StdEncoding.DecodeString()
	if  == nil {
		return , nil
	}

	return nil, fmt.Errorf("invalid string being converted to Bytes: %s %s", , )
}

// GetBytesBase64 return the []byte value of a flag with the given name
func ( *FlagSet) ( string) ([]byte, error) {
	,  := .getFlagType(, "bytesBase64", bytesBase64ValueConv)

	if  != nil {
		return []byte{}, 
	}

	return .([]byte), nil
}

// BytesBase64Var defines an []byte flag with specified name, default value, and usage string.
// The argument p points to an []byte variable in which to store the value of the flag.
func ( *FlagSet) ( *[]byte,  string,  []byte,  string) {
	.VarP(newBytesBase64Value(, ), , "", )
}

// BytesBase64VarP is like BytesBase64Var, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) ( *[]byte, ,  string,  []byte,  string) {
	.VarP(newBytesBase64Value(, ), , , )
}

// BytesBase64Var defines an []byte flag with specified name, default value, and usage string.
// The argument p points to an []byte variable in which to store the value of the flag.
func ( *[]byte,  string,  []byte,  string) {
	CommandLine.VarP(newBytesBase64Value(, ), , "", )
}

// BytesBase64VarP is like BytesBase64Var, but accepts a shorthand letter that can be used after a single dash.
func ( *[]byte, ,  string,  []byte,  string) {
	CommandLine.VarP(newBytesBase64Value(, ), , , )
}

// BytesBase64 defines an []byte flag with specified name, default value, and usage string.
// The return value is the address of an []byte variable that stores the value of the flag.
func ( *FlagSet) ( string,  []byte,  string) *[]byte {
	 := new([]byte)
	.BytesBase64VarP(, , "", , )
	return 
}

// BytesBase64P is like BytesBase64, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) (,  string,  []byte,  string) *[]byte {
	 := new([]byte)
	.BytesBase64VarP(, , , , )
	return 
}

// BytesBase64 defines an []byte flag with specified name, default value, and usage string.
// The return value is the address of an []byte variable that stores the value of the flag.
func ( string,  []byte,  string) *[]byte {
	return CommandLine.BytesBase64P(, "", , )
}

// BytesBase64P is like BytesBase64, but accepts a shorthand letter that can be used after a single dash.
func (,  string,  []byte,  string) *[]byte {
	return CommandLine.BytesBase64P(, , , )
}