Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateUsageString ¶
func GenerateUsageString(obj interface{}, properties Properties) string
GenerateUsageString generates usage string for given list of properties. This can be used to generate usage strings for commands.
For ex., given struct type account struct
AccountID string CompanyName string Email string }
and call like this
GenerateUsageString(&account{}, []Property{{Name: "AccountID", Required: true}, {Name: "CompanyName"}})
Returns:
AccountID=STRING [CompanyName=STRING]
func LoadProperties ¶
func LoadProperties(obj interface{}, properties Properties, argsList []string) error
LoadProperties loads properties from input arguments
func ValidatePropertyList ¶
func ValidatePropertyList(obj interface{}, props Properties)
ValidatePropertyList validates given list is valid for a given object
Types ¶
type Input ¶
Input represents parsed input arg.
type InputArg ¶
type InputArg string
InputArg - Represents command line input. This is in the format of: KEY=VALUE
type Properties ¶
type Properties []Property
Properties - list of properties.
func GetProperties ¶
func GetProperties(obj interface{}) Properties
GetProperties returns all properties in a given object
func (*Properties) Get ¶
func (pl *Properties) Get(propName string) *Property
Get returns the property by name.
func (*Properties) Remove ¶
func (pl *Properties) Remove(propName string)
Remove removes the given property from the list
func (*Properties) Sort ¶
func (pl *Properties) Sort(moveRequiredPropertiesFirst bool, alphabeticSort bool)
Sort sorts the properties
type Property ¶
type Property struct { Name string // Name of the property. The name should match the struct field name. Required bool // Specifies if the property is required. Default string // Default value for the property. Enums []string // List of enum values }
Property represents a single key/value pair that is used to collect input from user. For ex., in a command, a property represents user input. Since many killbill APIs have tons of properties, it is tedious and error prone to define each property manually. So, we also provide helpers to load properties from a given struct.