functions

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetCityDefinition = shell.SubstitutionFunction{
	Group:             "randomuser",
	Name:              "getcity",
	FunctionHelp:      "Get a random city of a consumer",
	Formats:           nil,
	OptionDescription: "",
	Options:           nil,
	Function:          GetCitySubstitute,
}
View Source
var GetDateDefinition = shell.SubstitutionFunction{
	Name:              "getdate",
	Group:             "date",
	FunctionHelp:      "Display formatted date value for key (default is now)",
	FormatDescription: "Format parameter selects interpretation of date/time:",
	Formats: []shell.SubstitutionItemHelp{
		{Item: "local", Description: "Display Local time value"},
		{Item: "utc", Description: "Display UTC time value"},
		{Item: "unix", Description: "Display Unix timestamp"},
	},
	OptionDescription: "Option is the Golang format for date display",
	Options: []shell.SubstitutionItemHelp{
		{Item: "2006-01-02 15:04:05", Description: "Default Golang format for date and time"},
		{Item: "Mon", Description: "Example Golang format for day of week"},
		{Item: "2006", Description: "Example Golang format for year"},
	},
	Function: GetDateSubstitute,
}

GetDateDefinition -- Display date based on display option provided (default is current time)

View Source
var GetEmailDefinition = shell.SubstitutionFunction{
	Group:             "randomuser",
	Name:              "getemail",
	FunctionHelp:      "Get a random email address of a consumer",
	Formats:           nil,
	OptionDescription: "",
	Options:           nil,
	Function:          GetEmailSubstitute,
}
View Source
var GetFirstNameDefinition = shell.SubstitutionFunction{
	Group:             "randomuser",
	Name:              "getfirstname",
	FunctionHelp:      "Get a random first name of a consumer",
	Formats:           nil,
	OptionDescription: "",
	Options:           nil,
	Function:          GetFirstNameSubstitute,
}
View Source
var GetLastNameDefinition = shell.SubstitutionFunction{
	Group:             "randomuser",
	Name:              "getlastname",
	FunctionHelp:      "Get a random last name of a consumer",
	Formats:           nil,
	OptionDescription: "",
	Options:           nil,
	Function:          GetLastNameSubstitute,
}
View Source
var GetPhoneDefinition = shell.SubstitutionFunction{
	Group:        "randomuser",
	Name:         "getphone",
	FunctionHelp: "Get a random phone number of a consumer",
	Formats: []shell.SubstitutionItemHelp{
		{"raw", "Raw unformatted phone number"},
		{"dots", "Format phone with periods"},
		{"dashes", "Format phone with dashes"},
	},
	OptionDescription: "",
	Options: []shell.SubstitutionItemHelp{
		{"main", "(Default) Provide the main phone number"},
		{"Cell", "Provide the cell phone number instead of main"},
	},
	Function: GetPhoneSubstitute,
}
View Source
var GetStateDefinition = shell.SubstitutionFunction{
	Group:        "randomuser",
	Name:         "getstate",
	FunctionHelp: "Get a random state of a consumer",
	Formats: []shell.SubstitutionItemHelp{
		{"default", "Full state name"},
		{"abbr", "Abbreviated state code"},
	},
	OptionDescription: "",
	Options:           nil,
	Function:          GetStateSubstitute,
}
View Source
var GetStreetDefinition = shell.SubstitutionFunction{
	Group:             "randomuser",
	Name:              "getstreet",
	FunctionHelp:      "Get a random street of a consumer",
	Formats:           nil,
	OptionDescription: "",
	Options:           nil,
	Function:          GetStreetSubstitute,
}
View Source
var GetZipDefinition = shell.SubstitutionFunction{
	Group:             "randomuser",
	Name:              "getzip",
	FunctionHelp:      "Get a random zip code of a consumer",
	Formats:           nil,
	OptionDescription: "",
	Options:           nil,
	Function:          GetZipSubstitute,
}
View Source
var ModifyDateDefinition = shell.SubstitutionFunction{
	Name:         "moddate",
	Group:        "date",
	FunctionHelp: "Set date value to an offset of current time (default to UTC) (Deprecated for SetDateOffset)",
	Formats: []shell.SubstitutionItemHelp{
		{Item: "local", Description: "Default to Local time value"},
		{Item: "utc", Description: "Default to UTC time value"},
		{Item: "unix", Description: "Default to Unix time value 0"},
	},
	OptionDescription: "Offset options (d=-2;s=+30;t=hns)",
	Options: []shell.SubstitutionItemHelp{
		{Item: "s", Description: "Add the specified seconds to time"},
		{Item: "n", Description: "Add the specified minutes to time"},
		{Item: "h", Description: "Add the specified hours to time"},
		{Item: "d", Description: "Add the specified days to date"},
		{Item: "m", Description: "Add the specified months to date"},
		{Item: "y", Description: "Add the specified years to the date"},
		{Item: "t", Description: "Truncate date/time component(s) to minimum (t=ymdhns)"},
	},
	Function: SetDateOffsetSubstitute,
}

ModifyDateDefinition -- Initialize the date based on an offset of current time

View Source
var NewGuidDefinition = shell.SubstitutionFunction{
	Name:              "newguid",
	Group:             "newguid",
	FunctionHelp:      "Generate a guid formated as specified",
	Formats:           nil,
	OptionDescription: "",
	Options:           nil,
	Function:          NewGuidSubstitute,
}
View Source
var NewIteratorDefinition = shell.SubstitutionFunction{
	Name:         "iterator",
	Group:        "iterator",
	FunctionHelp: "Return current value of a named (variable) iterator",
	Formats: []shell.SubstitutionItemHelp{
		{"varname", "Variable to be iterated"},
	},
	OptionDescription: "",
	Options: []shell.SubstitutionItemHelp{
		{"{increment}", "(Default = 1) Provide the integer increment"},
	},
	Function: NewIteratorSubstitute,
}

NewIteratorDefinition -- definition of iterator substitute function

View Source
var Quote = shell.SubstitutionFunction{
	Name:         "quote",
	Group:        "quote",
	FunctionHelp: "Quote a variable",
	Formats: []shell.SubstitutionItemHelp{
		{"var", "Option is a variable name"},
	},
	OptionDescription: "",
	Options:           nil,
	Function:          QuoteSubstitute,
}
View Source
var SetDateDefinition = shell.SubstitutionFunction{
	Name:         "setdate",
	Group:        "date",
	FunctionHelp: "Set a date value equal to the option string (default to min date)",
	Formats: []shell.SubstitutionItemHelp{
		{Item: "local", Description: "Parse date as Local"},
		{Item: "utc", Description: "Parse date as UTC"},
		{Item: "unix", Description: "Parse date as Unix timestamp"},
	},
	OptionDescription: "The desired date formatted to format string",
	Options: []shell.SubstitutionItemHelp{
		{Item: "2006-01-02T15:04:05", Description: "Default date format string"},
	},
	Function: SetDateSubstitute,
}

SetDateDefinition -- Sets the cached date value to value provided (default min date)

View Source
var SetDateOffsetDefinition = shell.SubstitutionFunction{
	Name:         "setdateoffset",
	Group:        "date",
	FunctionHelp: "Set date value to an offset of current time (default to UTC)",
	Formats: []shell.SubstitutionItemHelp{
		{Item: "local", Description: "Default to Local time value"},
		{Item: "utc", Description: "Default to UTC time value"},
		{Item: "unix", Description: "Default to Unix time value 0"},
	},
	OptionDescription: "Offset options (d=-2;s=+30;t=hns)",
	Options: []shell.SubstitutionItemHelp{
		{Item: "s", Description: "Add the specified seconds to time"},
		{Item: "n", Description: "Add the specified minutes to time"},
		{Item: "h", Description: "Add the specified hours to time"},
		{Item: "d", Description: "Add the specified days to date"},
		{Item: "m", Description: "Add the specified months to date"},
		{Item: "y", Description: "Add the specified years to the date"},
		{Item: "t", Description: "Truncate date/time component(s) to minimum (t=ymdhns)"},
	},
	Function: SetDateOffsetSubstitute,
}

SetDateOffsetDefinition -- Initialize the date based on an offset of current time

View Source
var ToLowerDefinition = shell.SubstitutionFunction{
	Name:         "tolower",
	Group:        "tolower",
	FunctionHelp: "Lower case an options parameter as identified by format",
	Formats: []shell.SubstitutionItemHelp{
		{"var", "Option is a variable name"},
	},
	OptionDescription: "",
	Options:           nil,
	Function:          ToLowerSubstitute,
}
View Source
var ToUpperDefinition = shell.SubstitutionFunction{
	Name:         "toupper",
	Group:        "toupper",
	FunctionHelp: "Upper case an options parameter as identified by format",
	Formats: []shell.SubstitutionItemHelp{
		{"var", "Option is a variable name"},
	},
	OptionDescription: "",
	Options:           nil,
	Function:          ToUpperSubstitute,
}

Functions

func GetCitySubstitute

func GetCitySubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

GetCitySubstitute -- Get a random city

func GetDateSubstitute

func GetDateSubstitute(cache interface{}, subname string, format string, option string) (value string, date interface{})

GetDateSubstitute -- Display date based on display option provided (default is current time)

func GetEmailSubstitute

func GetEmailSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

GetEmailSubstitute -- Get a random last name

func GetFirstNameSubstitute

func GetFirstNameSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

GetFirstNameSubstitute -- Get a random first name

func GetLastNameSubstitute

func GetLastNameSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

GetLastNameSubstitute -- Get a random last name

func GetPhoneSubstitute

func GetPhoneSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

GetPhoneSubstitute -- Get a random first name

func GetStateSubstitute

func GetStateSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

GetStateSubstitute -- Get a random state

func GetStreetSubstitute

func GetStreetSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

GetStreetSubstitute -- Get a random last name

func GetZipSubstitute

func GetZipSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

GetZipSubstitute -- Get a random zip code

func NewGuidSubstitute

func NewGuidSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

NewGuidSubstitute -- Implementatino of guid substitution

func NewIteratorSubstitute added in v1.3.0

func NewIteratorSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

NewIteratorSubstitute -- Implementatino of iterator substitution

func QuoteString

func QuoteString(input string) string

QuoteString -- Quote a string handling '\"' as well

func QuoteSubstitute

func QuoteSubstitute(cache interface{}, funcName string, format string, option string) (value string, data interface{})

Quote -- quote the input string including escaping inner quotes and escape sequences

func SetDateOffsetSubstitute added in v1.4.0

func SetDateOffsetSubstitute(cache interface{}, subname, format string, option string) (value string, date interface{})

SetDateOffsetSubstitute -- A function initializes date with offset from now

func SetDateSubstitute

func SetDateSubstitute(cache interface{}, subname, format string, option string) (value string, date interface{})

SetDateSubstitute -- Returns empty string but sets the date value used by the date group functions to option string

func ToLowerSubstitute

func ToLowerSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

ToLowerSubstitute -- returns the ToLower value from options parameter with format options to use the option parameter in a variable lookup

func ToUpperSubstitute

func ToUpperSubstitute(cache interface{}, subname string, format string, option string) (value string, data interface{})

ToUpperSubstitute -- returns the ToUpper value from options parameter with format options to use the option parameter in a variable lookup

Types

type Consumer

type Consumer struct {
	Gender   string          `json:"gender"`
	Name     NameDetails     `json:"name"`
	Location LocationDetails `json:"location"`
	Email    string          `json:"email"`
	Phone    string          `json:"phone"`
	Cell     string          `json:"cell"`
}

type LocationDetails

type LocationDetails struct {
	Street string      `json:"street"`
	City   string      `json:"city"`
	State  string      `json:"state"`
	Zip    json.Number `json:"postcode"`
}

type NameDetails

type NameDetails struct {
	First string `json:"first"`
	Last  string `json:"last"`
}

type Result

type Result struct {
	Consumers []Consumer `json:"results"`
}

Jump to

Keyboard shortcuts

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