Documentation
¶
Index ¶
- Constants
- Variables
- func ToBoolType(value string) (v, isBool bool)
- type EventArgs
- func (e *EventArgs) CheckCommand(cmd string) bool
- func (e *EventArgs) CompareCommand(cmd string) bool
- func (e *EventArgs) GetAsBool(name ...string) bool
- func (e *EventArgs) GetAsInteger(name ...string) (vI int64, ok bool)
- func (e *EventArgs) GetAsIntegerOrRaw(name ...string) (vI int64, ok bool)
- func (e *EventArgs) GetAsString(name ...string) string
- func (e *EventArgs) GetAsStringOrRaw(name ...string) string
- func (e *EventArgs) GetCommand() string
- func (e *EventArgs) GetFirstNoneEmptyValue() string
- func (e *EventArgs) GetFlag(names ...string) *Flag
- func (e *EventArgs) GetFlags() []Flag
- func (e *EventArgs) GetIndexFlag(index int) *Flag
- func (e *EventArgs) GetLength() int
- func (e *EventArgs) HasFlag(names ...string) bool
- func (e *EventArgs) HasFlags(names ...string) bool
- func (e *EventArgs) HasRawData() bool
- func (e *EventArgs) IsEmpty() bool
- func (e *EventArgs) IsEmptyOrRaw() bool
- type Flag
- func (f *Flag) GetAsBool() bool
- func (f *Flag) GetAsInteger() (vI int64, ok bool)
- func (f *Flag) GetAsString() string
- func (f *Flag) GetIndex() int
- func (f *Flag) GetName() string
- func (f *Flag) GetType() FlagType
- func (f *Flag) GetValue() interface{}
- func (f *Flag) GetValueAndType() (interface{}, FlagType)
- type FlagType
- type ParseOptions
Constants ¶
const ( NoneTypeStr = "None" BoolTypeStr = "bool" StringTypeStr = "string" UInt8TypeStr = "uint8" UInt16TypeStr = "uint16" UInt32TypeStr = "uint32" UInt64TypeStr = "uint64" Int8TypeStr = "int8" Int16TypeStr = "int16" Int32TypeStr = "int32" Int64TypeStr = "int64" )
const ( TrueHlc = "true" YesHlc = "yes" OnHlc = "on" FalseHlc = "false" NoHlc = "no" OffHlc = "off" )
common and global HLCs.
Variables ¶
var (
DefaultPrefixes = []rune{
'/',
'!',
}
)
Functions ¶
func ToBoolType ¶
Types ¶
type EventArgs ¶
type EventArgs struct {
// contains filtered or unexported fields
}
func ParseArgDefault ¶
func ParseArgWithOptions ¶ added in v1.0.6
func ParseArgWithOptions(text string, options *ParseOptions) (e *EventArgs, err error)
ParseArgWithOptions will parse the whole text into an EventArg and will return it.
func (*EventArgs) CheckCommand ¶
CheckCommand will compare the command of this event arg with the given command. This function is case insensitive, if you want to compare it case sensitive, then use CompareCommand method.
func (*EventArgs) CompareCommand ¶
CompareCommand will compare the command of this event arg with the given command. This function is case sensitive, if you want to compare it case insensitive, then use CheckCommand method.
func (*EventArgs) GetAsBool ¶
GetAsString will give you the boolean value of the flag with the specified name. if there is no flag with this name, or there is an error on our path, it will return you false.
func (*EventArgs) GetAsInteger ¶
GetAsString will give you the integer value of the flag with the specified name. if there is no flag with this name, or there is an error on our path, it will return you zero and false.
func (*EventArgs) GetAsIntegerOrRaw ¶
GetAsString will give you the integer value of the flag with the specified name. if there is no flag with this name, or there is an error on our path, it will return you zero and false.
func (*EventArgs) GetAsString ¶
GetAsString will give you the string value of the flag with the specified name. if there is no flag with this name, or there is an error on our path, it will return you an empty string.
func (*EventArgs) GetAsStringOrRaw ¶
GetAsStringOrRaw will give you the string value of the flag with the specified name. if there is no flag with this name, or there is an error on our path, it will return you the raw data in the EventArgs struct.
func (*EventArgs) GetCommand ¶
---------------------------------------------------------
func (*EventArgs) GetFirstNoneEmptyValue ¶
func (*EventArgs) GetIndexFlag ¶
func (*EventArgs) HasRawData ¶
func (*EventArgs) IsEmptyOrRaw ¶
type Flag ¶
type Flag struct {
// contains filtered or unexported fields
}
Flag is the options passed along with the commands by users. they should send them with prefix "--", but we will remove them in the pTools.
func (*Flag) GetAsInteger ¶
func (*Flag) GetAsString ¶
GetAsString will give you the value as an string. for example if value is `true` (with flag type of `bool`), then the string will be "true". or if it's 10(an integer), it will give you: "10".
func (*Flag) GetIndex ¶
GetIndex will return you the index of this flag. index of a flag is a unique int. even if the name of two flags are the same, their index will not be the same.
func (*Flag) GetName ¶
GetName will give you the name of this flag. it's not unique actually. for example:
`/command --test "hello" --test = "HI!"
func (*Flag) GetValue ¶
func (f *Flag) GetValue() interface{}
GetValue will return you the value of this flag. remember that value can be
func (*Flag) GetValueAndType ¶
GetValueAndType returns both value and type of this flag. originally it has internal usage, but maybe you want to use it in your own package, so I made it public!
type ParseOptions ¶ added in v1.0.6
type ParseOptions struct {
Prefixes []rune
}
func GetDefaultParseOptions ¶ added in v1.0.6
func GetDefaultParseOptions() *ParseOptions