flags

package
v0.0.0-...-2572d14 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFlagSet

func GetFlagSet(flagName string, cmd *cobra.Command) *pflag.FlagSet

GetFlagSet -

func GetFlagValues

func GetFlagValues(flagName string, flag *pflag.FlagSet, Type any) (ret any, err error)

GetFlagValues - return flag value by name

func GetFlagValuesT

func GetFlagValuesT[T any](flagName string, flag *pflag.FlagSet, Type T) (ret T, err error)

GetFlagValuesT - return typed flag value by name

func NewQueryParser

func NewQueryParser(cmd string, argToSql map[string]string) *query

func SetFlag

func SetFlag(fl *pflag.FlagSet, p FlagParams, Type any) (err error)

func SetFlagT

func SetFlagT[T any](fl *pflag.FlagSet, p FlagParams, Type T) (err error)

func ValidateStringValue

func ValidateStringValue(val string) (err error)

func ValidateStringValues

func ValidateStringValues(vals []string) error

Types

type FlagParams

type FlagParams struct {
	Name     string
	Key      string
	DefValue any
	Usage    string
	Example  string
	Group    string
}

type Flags

type Flags struct {
	// path to config file
	ConfigPath string `name:"config" key:"c" usage:"app config file"`
	// output in json format
	JsonFormat bool `name:"json" key:"j" usage:"enable extended output in the json format"`
	// trace hub server url
	ServerUrl string `name:"host" key:"H" usage:"trace-hub service address (format: <IP>:<port>)" eg:"tcp://127.0.0.1:9000"`
	// level of log
	LogLevel string `name:"log-level" usage:"log level: INFO|DEBUG|WARN|ERROR|PANIC|FATAL"`
	// verbose output mode
	VerboseMode bool `name:"verbose" key:"v" usage:"verbose output mode"`
	// time filter
	TimeFrom *time.Time `name:"time-from" usage:"specifies the start time of the time interval in the format '2024-10-08T12:30:00Z'"`
	// time filter
	TimeTo *time.Time `name:"time-to" usage:"specifies the end time of the time interval in the format '2024-10-08T12:30:00Z'"`
	// time filter
	TimeDuration *time.Duration `` /* 135-byte string literal not displayed */
	// follow mode on/off
	FollowMode bool `name:"follow" key:"f" usage:"follow or tail continuous output [Required --time Flag]"`
	// complex query filter parameter
	Query string `` /* 218-byte string literal not displayed */
	// traces ids
	TrId []uint `` /* 180-byte string literal not displayed */
	// nftables tables names
	Table []string `` /* 190-byte string literal not displayed */
	// nftables chains names
	Chain []string `name:"chain" gr:"trace" usage:"set filter by chain name. Supported multiple values (see --table Flag)" eg:"chain1,chain2"`
	// nftables jump to a target names
	JumpTarget []string `` /* 126-byte string literal not displayed */
	// nftables rules numbers
	RuleHandle []uint `name:"handle" gr:"trace" usage:"set filter by rule handle. Supported multiple values (see --trid Flag)" eg:"1,2,3,4,5"`
	// protocols family
	Family []string `` /* 130-byte string literal not displayed */
	// input network interfaces
	Iifname []string `` /* 147-byte string literal not displayed */
	// output network interfaces
	Oifname []string `` /* 146-byte string literal not displayed */
	// source mac addresses
	SMacAddr []string `` /* 152-byte string literal not displayed */
	// destination mac addresses
	DMacAddr []string `` /* 157-byte string literal not displayed */
	// source ip addresses
	SAddr []string `` /* 139-byte string literal not displayed */
	// destination ip addresses
	DAddr []string `` /* 144-byte string literal not displayed */
	// source ports
	SPort []uint `name:"sport" gr:"trace" usage:"set filter by source port. Supported multiple values (see --trid Flag)" eg:"80,443"`
	// destination ports
	DPort []uint `name:"dport" gr:"trace" usage:"set filter by destination port. Supported multiple values (see --trid Flag)" eg:"80,443"`
	// names of the security group for src ip
	SSgName []string `` /* 132-byte string literal not displayed */
	// names of the security group for dst ip
	DSgName []string `` /* 137-byte string literal not displayed */
	// names of the network for src ip
	SSgNet []string `` /* 149-byte string literal not displayed */
	// names of the network for dst ip
	DSgNet []string `` /* 154-byte string literal not displayed */
	// lengths of packets
	Length []uint `name:"len" gr:"trace" usage:"set filter by network packet length. Supported multiple values (see --trid Flag)" eg:"20,80"`
	// ip protocols (tcp/udp/icmp/...)
	IpProto []string `` /* 140-byte string literal not displayed */
	// verdicts of rules
	Verdict []string `` /* 155-byte string literal not displayed */
	// visor agents identifier
	AgentsIds []string `name:"agent-id" usage:"set filter by visor agents id Supported multiple values (see --table Flag)" eg:"tracer1,tracer2"`
}

func (*Flags) Action

func (f *Flags) Action(cmd *cobra.Command) (err error)

Action - execute commands according to flags

func (*Flags) Attach

func (f *Flags) Attach(cmd *cobra.Command, opts ...attachOptions) (err error)

Attach - attach flags to command

func (Flags) Clone

func (f Flags) Clone(fn func(f *Flags))

func (*Flags) GetFieldFlagParams

func (f *Flags) GetFieldFlagParams(fieldPtr any) FlagParams

func (*Flags) GetFlagParamsByGroup

func (f *Flags) GetFlagParamsByGroup(group string) (ret []FlagParams)

func (*Flags) InitFromCmd

func (f *Flags) InitFromCmd(cmd *cobra.Command) (err error)

func (*Flags) NameFromTag

func (f *Flags) NameFromTag(fieldPtr any) string

func (*Flags) ToTraceScopeModel

func (f *Flags) ToTraceScopeModel() (md model.TraceScopeModel, err error)

type QueryFlag

type QueryFlag string

func (QueryFlag) ToSql

func (q QueryFlag) ToSql() (ret string, err error)

type SliceT

type SliceT interface {
	~uint |
		~uint64 |
		~uint32 |
		~uint16 |
		~uint8 |
		~int |
		~int64 |
		~int32 |
		~int16 |
		~int8
}

type WithDefValues

type WithDefValues struct {
	Defvalues map[string]any
	// contains filtered or unexported fields
}

type WithExcludeFlags

type WithExcludeFlags struct {
	ExcludeFlags []string
	// contains filtered or unexported fields
}

type WithPersistentFlags

type WithPersistentFlags struct {
	Pflags map[string]*pflag.FlagSet
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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