package pflag

import 

// notExistErrorMessageType specifies which flavor of "flag does not exist"
// is printed by NotExistError. This allows the related errors to be grouped
// under a single NotExistError struct without making a breaking change to
// the error message text.
type notExistErrorMessageType int

const (
	flagNotExistMessage notExistErrorMessageType = iota
	flagNoSuchFlagMessage
	flagUnknownFlagMessage
	flagUnknownShorthandFlagMessage
)

// NotExistError is the error returned when trying to access a flag that
// does not exist in the FlagSet.
type NotExistError struct {
	name                string
	specifiedShorthands string
	messageType         notExistErrorMessageType
}

// Error implements error.
func ( *NotExistError) () string {
	switch .messageType {
	case flagNotExistMessage:
		return fmt.Sprintf("flag %q does not exist", .name)

	case flagNoSuchFlagMessage:
		return fmt.Sprintf("no such flag -%v", .name)

	case flagUnknownFlagMessage:
		return fmt.Sprintf("unknown flag: --%s", .name)

	case flagUnknownShorthandFlagMessage:
		 := rune(.name[0])
		return fmt.Sprintf("unknown shorthand flag: %q in -%s", , .specifiedShorthands)
	}

	panic(fmt.Errorf("unknown flagNotExistErrorMessageType: %v", .messageType))
}

// GetSpecifiedName returns the name of the flag (without dashes) as it
// appeared in the parsed arguments.
func ( *NotExistError) () string {
	return .name
}

// GetSpecifiedShortnames returns the group of shorthand arguments
// (without dashes) that the flag appeared within. If the flag was not in a
// shorthand group, this will return an empty string.
func ( *NotExistError) () string {
	return .specifiedShorthands
}

// ValueRequiredError is the error returned when a flag needs an argument but
// no argument was provided.
type ValueRequiredError struct {
	flag                *Flag
	specifiedName       string
	specifiedShorthands string
}

// Error implements error.
func ( *ValueRequiredError) () string {
	if len(.specifiedShorthands) > 0 {
		 := rune(.specifiedName[0])
		return fmt.Sprintf("flag needs an argument: %q in -%s", , .specifiedShorthands)
	}

	return fmt.Sprintf("flag needs an argument: --%s", .specifiedName)
}

// GetFlag returns the flag for which the error occurred.
func ( *ValueRequiredError) () *Flag {
	return .flag
}

// GetSpecifiedName returns the name of the flag (without dashes) as it
// appeared in the parsed arguments.
func ( *ValueRequiredError) () string {
	return .specifiedName
}

// GetSpecifiedShortnames returns the group of shorthand arguments
// (without dashes) that the flag appeared within. If the flag was not in a
// shorthand group, this will return an empty string.
func ( *ValueRequiredError) () string {
	return .specifiedShorthands
}

// InvalidValueError is the error returned when an invalid value is used
// for a flag.
type InvalidValueError struct {
	flag  *Flag
	value string
	cause error
}

// Error implements error.
func ( *InvalidValueError) () string {
	 := .flag
	var  string
	if .Shorthand != "" && .ShorthandDeprecated == "" {
		 = fmt.Sprintf("-%s, --%s", .Shorthand, .Name)
	} else {
		 = fmt.Sprintf("--%s", .Name)
	}
	return fmt.Sprintf("invalid argument %q for %q flag: %v", .value, , .cause)
}

// Unwrap implements errors.Unwrap.
func ( *InvalidValueError) () error {
	return .cause
}

// GetFlag returns the flag for which the error occurred.
func ( *InvalidValueError) () *Flag {
	return .flag
}

// GetValue returns the invalid value that was provided.
func ( *InvalidValueError) () string {
	return .value
}

// InvalidSyntaxError is the error returned when a bad flag name is passed on
// the command line.
type InvalidSyntaxError struct {
	specifiedFlag string
}

// Error implements error.
func ( *InvalidSyntaxError) () string {
	return fmt.Sprintf("bad flag syntax: %s", .specifiedFlag)
}

// GetSpecifiedFlag returns the exact flag (with dashes) as it
// appeared in the parsed arguments.
func ( *InvalidSyntaxError) () string {
	return .specifiedFlag
}