Documentation
¶
Overview ¶
Package arg provides implementations for the argument abstractions found in Package plugins.
Index ¶
- Variables
- type AlphanumericID
- type Choice
- type ChoiceElement
- type CodeBlock
- type Config
- type Date
- type DateTime
- type Decimal
- type DelimiterParser
- func (p *DelimiterParser) FormatArgs(_ plugin.ArgConfig, args []string, flags map[string]string) string
- func (p *DelimiterParser) FormatFlag(name string) string
- func (p *DelimiterParser) FormatUsage(_ plugin.ArgConfig, args []string) string
- func (p *DelimiterParser) Parse(args string, argConfig plugin.ArgConfig, s *state.State, ctx *plugin.Context) error
- type Duration
- type Flag
- type Integer
- type Link
- type LocalizedChoice
- type LocalizedChoiceElement
- type LocalizedConfig
- type LocalizedFlag
- type LocalizedOptionalArg
- type LocalizedRawType
- type LocalizedRequiredArg
- type NumericID
- type OptionalArg
- type RawType
- type RequiredArg
- type Text
- type Time
Constants ¶
This section is empty.
Variables ¶
var ( // CategoryAllowSearch is a global flag that defines whether categories may // be referenced by name. // If multiple matches are found, Category might ask the user to choose a // category through a reaction driven chooser embed. CategoryAllowSearch = true // CategoryChooserTimeout is the amount of time the user has to choose the // desired category from the chooser embed. CategoryChooserTimeout = 20 * time.Second )
var ( // VoiceChannelAllowSearch is a global flag that defines whether a // voice channels may be referenced by name. // If multiple matches are found, VoiceChannel might ask the user to choose // a category through a reaction driven chooser embed. VoiceChannelAllowSearch = true // VoiceChannelChooserTimeout is the amount of time the user has to choose // the desired voice channel from the chooser embed. VoiceChannelChooserTimeout = 20 * time.Second )
var ( // Emoji is the Type used for unicode and custom emojis. // Due to Discord-API limitations the type currently only supports custom // emojis from the invoking guild. // Use RawEmoji to use the raw emoji, which is not bound to such // limitations. // // Go type: *discord.Emoji Emoji plugin.ArgType = &emoji{customEmojis: true} // UnicodeEmoji is the type used for unicode emojis. // // Go type: *discord.Emoji UnicodeEmoji plugin.ArgType = &emoji{customEmojis: false} )
var ( // SimpleInteger is an Integer with no bounds. SimpleInteger plugin.ArgType = new(Integer) // PositiveInteger is an Integer with inclusive minimum 0. PositiveInteger plugin.ArgType = IntegerWithMin(0) // NegativeInteger is an Integer with inclusive maximum -1. NegativeInteger plugin.ArgType = IntegerWithMax(-1) )
var ( // SimpleDecimal is a decimal with no bounds. SimpleDecimal plugin.ArgType = new(Decimal) // PositiveDecimal is an Decimal with inclusive minimum 0. PositiveDecimal plugin.ArgType = DecimalWithMin(0) // NegativeDecimal is an Decimal with inclusive maximum -1. NegativeDecimal plugin.ArgType = DecimalWithMax(-1) )
var ( // SimpleDate is a Date with no bounds that doesn't require timezone // information. SimpleDate plugin.ArgType = new(Date) // DateWithTZ is a Date with no bounds that requires timezone information. DateWithTZ plugin.ArgType = &Date{NoIgnoreTimeZone: true} )
var Category plugin.ArgType = new(category)
Category is the type used for channels of type category. A category can either be referenced by id or through name matching, if CategoryAllowSearch is true.
If multiple categories match the given name, a reaction based chooser embed will be sent, that contains up to len(CategoryOptionEmojis) categories that match the search. The user will then be asked to choose by clicking the corresponding reaction.
Go type: *discord.Channel
var ChoiceCaseSensitive = false
ChoiceCaseSensitive is a global flag that defines whether choices should be case sensitive.
var Code plugin.ArgType = new(code)
Code is the type used for code enclosed in a markdown code block. Single, double, and triple backticks are permitted.
Go type: *CodeBlock
var Command plugin.ArgType = new(commandType)
Command is the type used for commands.
Go type: plugin.ResolvedCommand
var DefaultLocation *time.Location
DefaultLocation is the time.Location used if no other timezone information is available. If this is set to nil, timezone information must be provided either through the UTC offset in the argument or through LocationKey's corresponding value. If both LocationKey and DefaultLocation are nil, UTC offsets will be enforced.
var EmojiAllowIDs = false
EmojiAllowIDs is a global flag that defines whether Emojis may also be noted as plain Snowflakes.
var LocationKey interface{}
LocationKey is the key used to retrieve timezone information through the context. The type of the value must be *time.Location. If LocationKey is nil, no location is available, or the location is nil, DefaultLocation will be used. If both LocationKey and DefaultLocation are nil, UTC offsets will be enforced.
var Member plugin.ArgType = new(member)
Member is the Type used for members of a guild. It will always return an error, if the Command is called in a direct message.
A Member can either be a mention of a member, or, if enabled, an id of a guild member.
Go type: *discord.Member
var MemberAllowIDs = true
MemberAllowIDs is a global flag that defines whether Members may also be noted as plain Snowflakes.
var Module plugin.ArgType = new(moduleType)
Module is the type used for modules.
Go type: plugin.ResolvedModule
var Plugin plugin.ArgType = new(pluginType)
Plugin is the type used for plugins, i.e. commands and Modules. The generated data is guaranteed to be of one of the two go types, unless falling back to default, i.e. if using Plugin as type for an optional arg or a flag without a custom default value.
Go types: plugin.ResolvedCommand or plugin.ResolvedModule
var RawEmoji plugin.ArgType = new(rawEmoji)
RawEmoji is the Type for used for emojis that are either default emojis or custom ones from any guild. This means that an emoji is only guaranteed to be available to the bot, if it is unicode. If the emoji is custom, it is only guaranteed that it follows the pattern of an emoji. Unlike Emoji, this type only accepts actual emojis but no ids.
Go type: discord.APIEmoji
var RawParser = new(raw)
RawParser is a plugin.ArgParser that parses it's arguments literally.
It requires that only one RequiredArgument or OptionalArgument is defined, otherwise it will panic. To use custom type naming, RawType or LocalizedRawType can be used.
var RegularExpression plugin.ArgType = new(regularExpression)
RegularExpression is the Type used for regular expressions.
Go type: *regexp.Regexp
var Role plugin.ArgType = new(role)
Role is the Type used for roles. A role can either be a role mention or the id of the role.
It will return an error if used on a guild.
Go type: *discord.Role
var RoleAllowIDs = true
RoleAllowIDs is a global flag that defines whether Roles may also be noted as plain Snowflakes.
var ShellwordParser plugin.ArgParser = new(shellwordParser)
ShellwordParser is a plugin.ArgConfig that roughly follows the parsing rules of the Bourne shell.
Flags ¶
Flags can be placed both before and after arguments. For simplicity, flags always start with a single minus, double minuses are not permitted.
Arguments ¶
Arguments are space separated. To use arguments with whitespace quotes, both single and double, can be used. Additionally, lines of code as well as code blocks will be parsed as a single argument.
Escapes ¶
Escapes are only permitted if using double quotes. Valid escapes are '\\' and '\"', all other combinations will be parsed literally to make usage easier for users unaware of escapes.
var (
SimpleAlphanumericID plugin.ArgType = new(AlphanumericID)
)
var SimpleDateTime plugin.ArgType = new(DateTime)
SimpleDateTime is a DateTime with no bounds.
var SimpleDuration plugin.ArgType = new(Duration)
var ( // SimpleLink is a link that uses no custom regular expression. SimpleLink plugin.ArgType = new(Link) )
var ( // SimpleNumericID is a NumericID with no length boundaries and no custom name // or description. SimpleNumericID plugin.ArgType = new(NumericID) )
var ( // SimpleText is a Text with no length boundaries and no regular // expression. SimpleText plugin.ArgType = new(Text) )
var SimpleTime plugin.ArgType = new(Time)
SimpleTime is a Time with no bounds.
var Switch plugin.ArgType = new(typeSwitch)
Switch is the type used for bool flags. If the flag gets set, Switch returns true. It cannot be used as an argument type. Due to the special nature of this type, plugin.ArgParsers must handle it specially, i.e. expect no content for it.
Switch flags cannot be used as multi flags.
var TextChannel plugin.ArgType = new(textChannel)
TextChannel is the Type used for guild text channels and news channels. The channel must be on the same guild as the invoking one.
TextChannel will always fail if used in a direct message.
Go type: *discord.Channel
var TextChannelAllowIDs = false
TextChannelAllowIDs is a global flag that defines whether TextChannels may also be noted as plain Snowflakes.
var TimeZone plugin.ArgType = new(timeZone)
TimeZone is the Type used for time zones. A time zone is the name of a time zone in the IANA time zone database.
You must ensure that time zone information is available on your system, refer to time.LoadLocation for more information. Alternatively, you can import time/tzdata to add timezone data to the executable.
Go type: *time.Location
var User plugin.ArgType = new(user)
User is the Type used to specify users globally. The User doesn't have to be on the same guild as the invoking one. In contrast to member, this can also be used in direct messages. A User can either be a mention, or an id.
Gp type: *discord.User
var VoiceChannel plugin.ArgType = new(voiceChannel)
VoiceChannel is the type used for channels of type voice. A VoiceChannel can either be referenced by id or through name matching, if VoiceChannelAllowSearch is true.
If multiple voice channels match the given name, a reaction based chooser embed will be sent, that contains up to len(VoiceChannelOptionEmojis) categories that match the search. The user will then be asked to choose by clicking the corresponding reaction.
Go type: *discord.Channel
Functions ¶
This section is empty.
Types ¶
type AlphanumericID ¶
type AlphanumericID struct { // CustomName allows you to set a custom name for the id. // If not set, the default name will be used. CustomName *i18n.Config // CustomDescription allows you to set a custom description for the id. // If not set, the default description will be used. CustomDescription *i18n.Config // MinLength is the inclusive minimum length the ID may have. MinLength uint // MaxLength is the inclusive maximum length the id may have. // If MaxLength is 0, the id won't have a maximum. MaxLength uint // Regexp is the regular expression the id needs to match to pass. // If Regexp is set to nil/zero, any id within the bounds will pass. // // If matching fails, the corresponding RegexpErrorX will be returned. Regexp *regexp.Regexp // RegexpErrorArg is the error message used if an argument doesn't match // the regular expression defined. // If you want an unlocalized error, just fill Fallback.Other field of the // config. // // Available Placeholders are: // // • name - the name of the argument // • raw - the raw argument // • position - the position of the id (1-indexed) // • regexp - the regular expression that needs to be matched // // Defaults to: idRegexpNotMatchingErrorArg RegexpErrorArg *i18n.Config // RegexpErrorFlag is the error message used if a flag doesn't match the // regular expression defined. // If you want an unlocalized error, just fill Fallback.Other field of the // config. // // Available Placeholders are: // // • name - the full name of the flag // • used_name - the name of the flag the invoking user used // • raw - the raw flag without the flags name // • regexp - the regular expression that needs to be matched // // Defaults to: idRegexpNotMatchingErrorFlag RegexpErrorFlag *i18n.Config }
AlphanumericID is a Type for alphanumeric ids. By default AlphanumericIDs share the same name and description as a NumericID, simply their definition differs.
In contrast to a NumericID, a AlphanumericID returns strings and can handle numbers that exceed NumericIDs 64 bit limit.
Go type: string
func (AlphanumericID) GetDefault ¶
func (id AlphanumericID) GetDefault() interface{}
func (AlphanumericID) GetDescription ¶
func (id AlphanumericID) GetDescription(l *i18n.Localizer) string
func (AlphanumericID) Parse ¶
func (id AlphanumericID) Parse(_ *state.State, ctx *plugin.ParseContext) (interface{}, error)
type Choice ¶
type Choice []ChoiceElement
Choice is an unlocalized enum type.
func (Choice) GetDefault ¶
func (c Choice) GetDefault() interface{}
GetDefault tries to derive the default type from the value of the first choice. If the choice is empty, Default returns nil.
type ChoiceElement ¶
type ChoiceElement struct { // Name is the name of the element. Name string // Aliases are optional aliases for the element. Aliases []string // Value is the value the element corresponds to. // If this is nil, the name of the choice will be used. Value interface{} }
ChoiceElement is a single element of a choice.
type CodeBlock ¶
type CodeBlock struct { // Language is the language the user specified, if any. Language string // Code is the code itself. // Language and backticks are removed. Code string // QtyBackticks is the number of backticks the user used. // Guaranteed to be 1, 2, or 3 in error != nil scenarios. QtyBackticks int }
CodeBlock is the type returned by Code.
type Config ¶
type Config struct { // RequiredArgs are the required arguments. RequiredArgs []RequiredArg // OptionalArgs are the optional arguments. OptionalArgs []OptionalArg // Variadic specifies whether the last argument is variadic, i.e. it // may be specified more than once. Variadic bool // Flags are the flags. Flags []Flag // contains filtered or unexported fields }
Config is an unlocalized plugin.ArgConfig.
func (*Config) GetOptionalArgs ¶
func (c *Config) GetOptionalArgs() []plugin.OptionalArg
func (*Config) GetRequiredArgs ¶
func (c *Config) GetRequiredArgs() []plugin.RequiredArg
func (*Config) IsVariadic ¶
type Date ¶
type Date struct { // Min is the inclusive minimum date. Min time.Time // Max is the inclusive maximum time. Max time.Time // NoIgnoreTimeZone specifies, whether timezone information should not be // ignored. // If set to false, all time.Times generated by this Date will be in the // UTC time zone, regardless of whether locations through DefaultLocation // or LocationKey are available, or the user specified a UTC offset. // Furthermore, even if global settings require UTC offsets, they won't be // required if NoIgnoreTimeZone is set to false. NoIgnoreTimeZone bool }
Date is the type used for dates.
A Date can either be specified without a UTC offset following the format of '2006-01-02', or with a UTC offset: '2006-01-02 -0700'. However, timezones can be disabled, in which case UTC offsets will be ignored.
If the first format is used, DefaultLocation will be assumed as time zone, unless the context has a variable called "location" that is of type *time.Location. If both are nil, UTC offsets will be required.
Go type: time.Time
func (Date) GetDefault ¶
func (d Date) GetDefault() interface{}
type DateTime ¶
type DateTime struct { // Min is the inclusive minimum date. Min time.Time // Max is the inclusive maximum time. Max time.Time }
DateTime is the type used for combinations of a date and a time.
A DateTime can either be specified without a UTC offset following the format of '2006-01-02 15:04', or with a UTC offset: '2006-01-02 15:04 -0700'. In the first case, DefaultLocation will be assumed as time zone, unless the context has a variable called "location" that is of type *time.Location. If both are nil, UTC offsets will be required.
Go type: time.Time
func (DateTime) GetDefault ¶
func (t DateTime) GetDefault() interface{}
type Decimal ¶
Decimal is the Type used for decimal numbers.
Go type: float64
func DecimalWithBounds ¶
DecimalWithBounds creates a new Decimal with the passed inclusive minimum and maximum.
func DecimalWithMax ¶
DecimalWithMax creates a new Decimal with the passed inclusive maximum.
func DecimalWithMin ¶
DecimalWithMin creates a new Decimal with the passed inclusive minimum.
func (Decimal) GetDefault ¶
func (i Decimal) GetDefault() interface{}
type DelimiterParser ¶
type DelimiterParser struct { // Delimiter is the delimiter used by the parser. // It can be escaped by using the delimiter twice in a row, e.g. ",," if // using ',' as a delimiter. // // Minus ('-'), Space (' ') and New-Lines ('\n') are not permitted and may // lead to unexpected behavior. // // Default: ',' Delimiter rune }
DelimiterParser is a plugin.ArgParser, that uses a custom delimiter to separate flags and arguments. Literal delimiters can be escaped by using the delimiter twice in a row.
Flags may be placed in front of the arguments.
If the first argument starts with a minus, the minus must be escaped through a double minus to avoid confusion with a flag.
Examples ¶
The below examples use ',' as the delimiter.
cmd -flag1 abc, -flag2, first arg, second arg,, with a comma in it cmd --first arg using a minus escape
func (*DelimiterParser) FormatArgs ¶
func (p *DelimiterParser) FormatArgs(_ plugin.ArgConfig, args []string, flags map[string]string) string
FormatArgs formats the arguments. It uses the parser's Delimiter followed by a space to separate arguments and flags.
func (*DelimiterParser) FormatFlag ¶
func (p *DelimiterParser) FormatFlag(name string) string
func (*DelimiterParser) FormatUsage ¶
func (p *DelimiterParser) FormatUsage(_ plugin.ArgConfig, args []string) string
type Duration ¶
type Duration struct { // Min is the inclusive minimum of the duration. // All time.Durations below 0 will be replaced with 0. // // Defaults to 0. Min time.Duration // Max is the inclusive maximum of the duration. // If Max is 0, there won't be an upper bound. Max time.Duration }
Duration is the Type used for spans of time. Although time.Duration permits negative durations, Duration will return an error if it receives a negative duration, seeing as they are rarely desired.
Go type: time.Duration
func (Duration) GetDefault ¶
func (d Duration) GetDefault() interface{}
type Flag ¶
type Flag struct { // Name is the name of the flag. Name string // Aliases contains the optional aliases of the flag. Aliases []string // Type is the type of the flag. Type plugin.ArgType // Default is the default value of the flag, and is used if the flag // isn't set. // // If Default is (interface{})(nil), Type.GetDefault() will be used. Default interface{} // Description is an optional short description of the flag. Description string // Multi specifies whether this flag can be used multiple times. Multi bool }
Flag is an unlocalized flag.
func (Flag) GetAliases ¶
func (Flag) GetDefault ¶
func (f Flag) GetDefault() interface{}
type Integer ¶
type Integer struct { // Min is the inclusive minimum of the integer. // If Min is nil, there is no minimum. Min *int // Max is the inclusive maximum of the integer. // If Max is nil, there is no maximum. Max *int }
Integer is the type used for whole numbers.
Go type: int
func IntegerWithBounds ¶
IntegerWithBounds creates a new Integer with the passed inclusive minimum and maximum.
func IntegerWithMax ¶
IntegerWithMax creates a new Integer with the passed inclusive maximum.
func IntegerWithMin ¶
IntegerWithMin creates a new Integer with the passed inclusive minimum.
func (Integer) GetDefault ¶
func (i Integer) GetDefault() interface{}
type Link ¶
type Link struct { // Validator checks if the passed *url.URL is valid. // // By default, Validator will check if the scheme is either 'http' or // 'https'. Validator func(u *url.URL) bool // ErrorArg is the error message used if an argument doesn't pass the // validator, or url.ParseRequestURI. // If you want an unlocalized error, just fill Fallback.Other field of the // config. // // Available Placeholders are: // // • name - the name of the argument // • raw - the raw argument // • position - the position of the id (1-indexed) // • regexp - the regular expression that needs to be matched // // Defaults to: linkInvalidErrorArg ErrorArg *i18n.Config // ErrorFlag is the error message used if an argument doesn't pass the // validator, or url.ParseRequestURI. // If you want an unlocalized error, just fill Fallback.Other field of the // config. // // Available Placeholders are: // // • name - the full name of the flag // • used_name - the name of the flag the invoking user used // • raw - the raw flag without the flags name // • regexp - the regular expression that needs to be matched // // Defaults to: linkInvalidErrorFlag ErrorFlag *i18n.Config }
Link is the Type used for URLs.
Go type: string
func (Link) GetDefault ¶
func (l Link) GetDefault() interface{}
type LocalizedChoice ¶
type LocalizedChoice []LocalizedChoiceElement
LocalizedChoice is a localized enum type.
func (LocalizedChoice) GetDefault ¶
func (c LocalizedChoice) GetDefault() interface{}
GetDefault tries to derive the default type from the value of the first choice. If the choice is empty, Default returns nil.
func (LocalizedChoice) GetDescription ¶
func (c LocalizedChoice) GetDescription(l *i18n.Localizer) string
func (LocalizedChoice) Parse ¶
func (c LocalizedChoice) Parse(_ *state.State, ctx *plugin.ParseContext) (interface{}, error)
type LocalizedChoiceElement ¶
type LocalizedChoiceElement struct { // Names are the names used for the element. Names []*i18n.Config // Value is the value the element corresponds to. Value interface{} }
LocalizedChoiceElement is a single element in a localized choice.
type LocalizedConfig ¶
type LocalizedConfig struct { // RequiredArgs are the required arguments. RequiredArgs []LocalizedRequiredArg // OptionalArgs are the optional arguments. OptionalArgs []LocalizedOptionalArg // Variadic specifies whether the last argument is variadic, i.e. it // may be specified more than once. Variadic bool // Flags are the flags. Flags []LocalizedFlag // contains filtered or unexported fields }
func (*LocalizedConfig) GetFlags ¶
func (c *LocalizedConfig) GetFlags() []plugin.Flag
func (*LocalizedConfig) GetOptionalArgs ¶
func (c *LocalizedConfig) GetOptionalArgs() []plugin.OptionalArg
func (*LocalizedConfig) GetRequiredArgs ¶
func (c *LocalizedConfig) GetRequiredArgs() []plugin.RequiredArg
func (*LocalizedConfig) IsVariadic ¶
func (c *LocalizedConfig) IsVariadic() bool
type LocalizedFlag ¶
type LocalizedFlag struct { // Name is the name of the flag. Name string // Aliases contains the optional aliases of the flag. Aliases []string // Type is the type of the flag. Type plugin.ArgType // Default is the default value of the flag, and is used if the flag // isn't set. // // If Default is (interface{})(nil), Type.GetDefault() will be used. Default interface{} // Description is an optional short description of the flag. Description *i18n.Config // Multi specifies whether this flag can be used multiple times. Multi bool }
LocalizedFlag is a localized flag.
func (LocalizedFlag) GetAliases ¶
func (f LocalizedFlag) GetAliases() []string
func (LocalizedFlag) GetDefault ¶
func (f LocalizedFlag) GetDefault() interface{}
func (LocalizedFlag) GetDescription ¶
func (f LocalizedFlag) GetDescription(l *i18n.Localizer) string
func (LocalizedFlag) GetName ¶
func (f LocalizedFlag) GetName() string
func (LocalizedFlag) GetType ¶
func (f LocalizedFlag) GetType() plugin.ArgType
func (LocalizedFlag) IsMulti ¶
func (f LocalizedFlag) IsMulti() bool
type LocalizedOptionalArg ¶
type LocalizedOptionalArg struct { // Name is the name of the argument. Name *i18n.Config // Type is the type of the argument. Type plugin.ArgType // Default is the default value of the argument. // // If Default is (interface{})(nil), Type.GetDefault() will be used. Default interface{} // Description is an optional short description of the argument. Description *i18n.Config }
LocalizedOptionalArg is an localized optional argument.
func (LocalizedOptionalArg) GetDefault ¶
func (o LocalizedOptionalArg) GetDefault() interface{}
func (LocalizedOptionalArg) GetDescription ¶
func (o LocalizedOptionalArg) GetDescription(l *i18n.Localizer) string
func (LocalizedOptionalArg) GetName ¶
func (o LocalizedOptionalArg) GetName(l *i18n.Localizer) string
func (LocalizedOptionalArg) GetType ¶
func (o LocalizedOptionalArg) GetType() plugin.ArgType
type LocalizedRawType ¶
type LocalizedRawType struct { // Name is the name of the type. Name *i18n.Config // Description is the description of the type. Description *i18n.Config }
LocalizedRawType is a localized plugin.ArgType that allows specifying a custom name and description.
Go type: string
func (LocalizedRawType) GetDefault ¶
func (t LocalizedRawType) GetDefault() interface{}
func (LocalizedRawType) GetDescription ¶
func (t LocalizedRawType) GetDescription(l *i18n.Localizer) string
func (LocalizedRawType) Parse ¶
func (t LocalizedRawType) Parse(_ *state.State, ctx *plugin.ParseContext) (interface{}, error)
type LocalizedRequiredArg ¶
type LocalizedRequiredArg struct { // Name is the name of the argument. Name *i18n.Config // Type is the type of the argument. Type plugin.ArgType // Description is an optional short description of the argument. Description *i18n.Config }
LocalizedRequiredArg is a localized required argument.
func (LocalizedRequiredArg) GetDescription ¶
func (r LocalizedRequiredArg) GetDescription(l *i18n.Localizer) string
func (LocalizedRequiredArg) GetName ¶
func (r LocalizedRequiredArg) GetName(l *i18n.Localizer) string
func (LocalizedRequiredArg) GetType ¶
func (r LocalizedRequiredArg) GetType() plugin.ArgType
type NumericID ¶
type NumericID struct { // CustomName allows you to set a custom name for the id. // If not set, the default name will be used. CustomName *i18n.Config // CustomDescription allows you to set a custom description for the id. // If not set, the default description will be used. CustomDescription *i18n.Config // MinLength is the inclusive minimum length the id may have. MinLength uint // MaxLength is the inclusive maximum length the id may have. // If MaxLength is 0, the id won't have a maximum. MaxLength uint }
NumericID is the Type used for ids consisting only of numbers. Additionally, ids must be positive. By default, NumericIDs share the same name and description as AlphanumericIDs, simply their definition differs.
In contrast to an AlphaNumericID, a NumericID returns uint64s. This also means, it is capped at 64 bit positive integers. If your IDs exceed that limit, use a AlphanumericID with a regular expression.
Go type: uint64
func (NumericID) GetDefault ¶
func (id NumericID) GetDefault() interface{}
type OptionalArg ¶
type OptionalArg struct { // Name is the name of the argument. Name string // Type is the type of the argument. Type plugin.ArgType // Default is the default value of the argument. // // If Default is (interface{})(nil), Type.GetDefault() will be used. Default interface{} // Description is an optional short description of the argument. Description string }
OptionalArg is an unlocalized optional argument.
func (OptionalArg) GetDefault ¶
func (o OptionalArg) GetDefault() interface{}
func (OptionalArg) GetDescription ¶
func (o OptionalArg) GetDescription(*i18n.Localizer) string
func (OptionalArg) GetType ¶
func (o OptionalArg) GetType() plugin.ArgType
type RawType ¶
type RawType struct { // Name is the name of the type. Name string // Description is the description of the type. Description string }
RawType is a unlocalized plugin.ArgType that allows specifying a custom name and description.
Go type: string
func (RawType) GetDefault ¶
func (t RawType) GetDefault() interface{}
type RequiredArg ¶
type RequiredArg struct { // Name is the name of the argument. Name string // Type is the type of the argument. Type plugin.ArgType // Description is an optional short description of the argument. Description string }
RequiredArg is an unlocalized required argument.
func (RequiredArg) GetDescription ¶
func (r RequiredArg) GetDescription(*i18n.Localizer) string
func (RequiredArg) GetType ¶
func (r RequiredArg) GetType() plugin.ArgType
type Text ¶
type Text struct { // CustomName allows you to set a custom name for the id. // If not set, the default name will be used. CustomName *i18n.Config // CustomDescription allows you to set a custom description for the id. // If not set, the default description will be used. CustomDescription *i18n.Config // MinLength is the inclusive minimum length the text may have. MinLength uint // MaxLength is the inclusive maximum length the text may have. // If MaxLength is 0, the id won't have a maximum. MaxLength uint // Regexp is the regular expression the text must match. // If Regexp is set to nil/zero, any text within the bounds will pass. // // If matching fails, the corresponding RegexpErrorX will be returned. Regexp *regexp.Regexp // RegexpErrorArg is the error message used if an argument doesn't match // the regular expression defined. // If you want to use an unlocalized error, use a i18n.Config with a set // Fallback.Other. // // Available Placeholders are: // // • name - the name of the argument // • raw - the raw argument // • position - the position of the id (1-indexed) // • regexp - the regular expression that needs to be matched // // Defaults to: regexpNotMatchingErrorArg RegexpErrorArg *i18n.Config // RegexpErrorFlag is the error message used if a flag doesn't match the // regular expression defined. // If you want to use an unlocalized error, use a i18n.Config with a set // Fallback.Other. // // Available Placeholders are: // // • name - the full name of the flag // • used_name - the name of the flag the invoking user used // • raw - the raw flag without the flags name // • regexp - the regular expression that needs to be matched // // Defaults to: regexpNotMatchingErrorFlag RegexpErrorFlag *i18n.Config }
Text is the Type for a string.
Go type: string
func (Text) GetDefault ¶
func (t Text) GetDefault() interface{}
type Time ¶
type Time struct { // Min is the inclusive minimum time. Min time.Time // Max is the inclusive maximum time. Max time.Time }
Time is the type used for points in time.
A time can either be specified without a UTC offset following the format of '15:04', or with a UTC offset: '15:04 -0700'. In the first case, DefaultLocation will be assumed as time zone, unless the context has an element stored under the key LocationKey that is of type *time.Location. If both are nil, UTC offsets will be required.
Go type: time.Time
func (Time) GetDefault ¶
func (t Time) GetDefault() interface{}
Source Files
¶
- arg.go
- channel_types.go
- choice_type.go
- code_type.go
- delimiter_lexer.go
- delimiter_parser.go
- emoji_types.go
- numeric_types.go
- parse_helper.go
- parser_terms.go
- plugin_types.go
- raw_parser.go
- regular_expression_type.go
- role_types.go
- shellword_parser.go
- switch_type.go
- test_util.go
- text_types.go
- time_types.go
- type_terms.go
- user_types.go
- util.go