parameters

package
v0.0.0-...-91b6c6a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TypeString = &command.BaseType{Name: "string"}
	TypeInt    = &command.BaseType{Name: "int"}
	TypeBool   = &command.BaseType{Name: "bool"}
)
View Source
var ParameterBool = &command.ParameterType{
	BaseType: TypeBool,
	Name:     "bool",
	Parser: func(ctx *command.Context, index int, args []string) (any, error) {
		b, err := strconv.ParseBool(args[index])
		if err != nil {
			return nil, errors.New(
				ctx.Lang.Validations.ParametersValidations.InvalidBool.Str(),
			)
		}
		return b, err
	},
}
View Source
var ParameterInt = &command.ParameterType{
	BaseType: TypeInt,
	Name:     "int",
	Parser: func(ctx *command.Context, index int, args []string) (any, error) {
		i, err := strconv.Atoi(args[index])
		if err != nil {
			return nil, errors.New(
				ctx.Lang.Validations.ParametersValidations.InvalidInt.Str(),
			)
		}
		return i, err
	},
}
View Source
var ParameterLowerCasedString = &command.ParameterType{
	BaseType: TypeString,
	Name:     "lower cased string",
	Parser: func(ctx *command.Context, index int, args []string) (any, error) {
		return strings.ToLower(args[index]), nil
	},
}
View Source
var ParameterString = &command.ParameterType{
	BaseType: TypeString,
	Name:     "string",
	Parser: func(ctx *command.Context, index int, args []string) (any, error) {
		return args[index], nil
	},
}
View Source
var ParameterText = &command.ParameterType{
	BaseType: TypeString,
	Name:     "text",
	Parser: func(ctx *command.Context, index int, args []string) (any, error) {
		return strings.Join(args[index:], " "), nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL