Documentation
¶
Index ¶
- Constants
- func ArgtpToString(tp int) string
- func BlackTxt(txt string) string
- func BlueTxt(txt string) string
- func CyanTxt(txt string) string
- func Err(msg string) error
- func ErrF(format string, n ...any) error
- func GreenTxt(txt string) string
- func InitLib(com []string, fls []LFlag) error
- func MagentaTxt(txt string) string
- func RedTxt(txt string) string
- func SErrF(format string, n ...any) string
- func Unimpl(msg string)
- func UnimplFunc(f string)
- func UnwrapStrFlag(flag string) string
- func WhiteTxt(txt string) string
- func YellowTxt(txt string) string
- type Anter
- func (an *Anter) GetCom() Arg
- func (an *Anter) GetFlagBool(flag string) (bool, error)
- func (an *Anter) GetFlagFloat(flag string, base int) (float64, error)
- func (an *Anter) GetFlagFloat32(flag string) (float32, error)
- func (an *Anter) GetFlagFloat64(flag string) (float64, error)
- func (an *Anter) GetFlagInt(flag string, bitSize int) (int64, error)
- func (an *Anter) GetFlagInt16(flag string) (int16, error)
- func (an *Anter) GetFlagInt32(flag string) (int32, error)
- func (an *Anter) GetFlagInt64(flag string) (int64, error)
- func (an *Anter) GetFlagInt8(flag string) (int8, error)
- func (an *Anter) GetFlagString(flag string) (string, error)
- func (an *Anter) GetFlagUInt(flag string, base int) (uint64, error)
- func (an *Anter) GetFlagUInt16(flag string) (uint16, error)
- func (an *Anter) GetFlagUInt32(flag string) (uint32, error)
- func (an *Anter) GetFlagUInt64(flag string) (uint64, error)
- func (an *Anter) GetFlagUInt8(flag string) (uint8, error)
- func (an *Anter) GetFlagValue(SFlag string) (string, error)
- func (an *Anter) IsComPresent_Str(com string) bool
- type AnterIter
- type Arg
- type LFlag
Constants ¶
const ( FTYPE_UNKNOWN = iota /* It is used to indicate an error */ FTYPE_BOOL /* It means that the flag didn't expect any value */ FTYPE_VALUE /* It specifies that the flag expect a value */ )
LFlag.tp
const ( F_SINGLE_DASHED = 1 << iota //TODO: Add support for shorthand flags F_DOUBLE_DASHED F_CONCAT F_DEFAULT_FLAG = 3 )
LFlag.flag
const ( ARGTP_EOA = iota ARGTP_COMMAND ARGTP_FLAG ARGTP_VALUE ARGTP_BINPATH ARGTP_UNKNOWN = -1 ARGF_NONE = -1 )
Arg type: "--flag" -> flag "new" -> Command "--flag=value" | "--flag value" -> value
const ( NO_COLOR_ASCII_CODE = "\033[0m" BLACK_ASCCI_CODE = "\033[0;30m" RED_ASCII_CODE = "\033[0;31m" GREEN_ASCII_CODE = "\033[0;32m" YELLOW_ASCII_CODE = "\033[0;33m" BLUE_ASCII_CODE = "\033[0;34m" MAGENTA_ASCII_CODE = "\033[0;35m" CYAN_ASCCI_CODE = "\033[0;36m" WHITE_ASCCI_CODE = "\033[0;37m" )
Variables ¶
This section is empty.
Functions ¶
func ArgtpToString ¶
TODO: This function should be a part of the Arg structure
func MagentaTxt ¶
func UnimplFunc ¶
func UnimplFunc(f string)
func UnwrapStrFlag ¶
TODO: add support for single dashed flag:
"-h" -> "h" | "help"
This function remove the flag header ("--" | "-") from the provided string and returns the result
Types ¶
type Anter ¶
type Anter struct {
// contains filtered or unexported fields
}
func AnalArg ¶
This function analise the argv from os.Argv and stores the info in the Anter structure
func (*Anter) GetCom ¶ added in v0.8.0
It return the first command that occured An EOA Arg is return if it wasn't present
func (*Anter) GetFlagBool ¶
The 'flag' can be passed like "--flag" | "flag" Return true if the flag was provided false if it wasn't provided or due to an error
func (*Anter) GetFlagFloat ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagFloat32 ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagFloat64 ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagInt ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagInt16 ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagInt32 ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagInt64 ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagInt8 ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagString ¶
This function gets the flag value if it was a valuable flag and returns it The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagUInt ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagUInt16 ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagUInt32 ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagUInt64 ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagUInt8 ¶
The flag can be provided like "--flag" | "flag"
func (*Anter) GetFlagValue ¶
For boolean flag it return TRUE | FALSE based on
if the flag was provied or not
For valuable flag it returns the value if
given or an error
If the flag was not provided during initialization it return an error If the flag was not given by the user it returns an error
func (*Anter) IsComPresent_Str ¶ added in v0.8.0
TODO? shall we call this function without the _Str suffix? It checks if the provided command (as a string) was given by the user
type AnterIter ¶ added in v0.9.0
type AnterIter struct {
// contains filtered or unexported fields
}
func (*AnterIter) Get ¶ added in v0.9.0
It gets the current argument If there are no more arguments it returns an EOA Arg
type Arg ¶
type Arg struct {
// contains filtered or unexported fields
}
func (*Arg) AIdx ¶ added in v0.8.0
Warning the returned idx doesn't always mean that the specified argument is in os.Arg[a_indx]
func (*Arg) IsValidType ¶ added in v0.8.0
An invalid type is any argument that has his type == ARGTP_UNKNOWN
type LFlag ¶
type LFlag struct {
// contains filtered or unexported fields
}
func NewDefFlag ¶ added in v0.10.0
like NewFlag but flag = F_DEFAULT_FLAG
func NewFlag ¶ added in v0.10.0
-name whould be provided without any dashes -tp indicates the flag type:
[-] FTYPE_VALUE -> Expects a value after the flag [-] FTYPE_BOOL -> It is used to activate a flag
- flag indicates some other flag for the flag [You can use the F_DEFAULT_FLAG to activate default flags]