utils

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: GPL-3.0 Imports: 5 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// GroupAPI is the group API scope use in this package
	GroupAPI = "sxlibs.k8s.startx.fr"
	// GroupName is the group name use in this package
	GroupName = "utils"
)
View Source
const (
	// GroupNameArgParser is the group name use in this package
	GroupNameArgParser = "utils.args"
)

Variables

View Source
var IsDebug bool

The global IsDebug var

Functions

func DisplayHelpCmd

func DisplayHelpCmd()

Function used to display answer to the help command (or flag)

func DisplayVersion

func DisplayVersion()

Function used to display answer to the help command (or flag)

func ExecuteCommand

func ExecuteCommand(command string)

Function used to display the list of quotas

func RemoveFlag

func RemoveFlag(args []string, flagToRemove string) []string

func RemoveFlagFromPos

func RemoveFlagFromPos(args []string, pos int) []string

func WriteFile

func WriteFile(filePath string, content string) error

RQExporterWriteToFile record into a file the given content

Types

type ArgParser

type ArgParser struct {
	SourceArgs []string
	ParsedArgs []string
	Binary     string
	TopAction  string
	SubAction  string
	IsHelp     bool
	IsDebug    bool
}

ArgParser is a definition for displaying message for a command line

func NewArgParser

func NewArgParser(sourceArgs []string) *ArgParser

Initialize a ArgParser object ex:

display := NewArgParser("main",true)

func (*ArgParser) Debug

func (argParser *ArgParser) Debug() *ArgParser

Display the content of the ArgParser

func (*ArgParser) GetFlagNextVal

func (argParser *ArgParser) GetFlagNextVal(flag string) string

used to scan arguments and detect if command has a special flag

func (*ArgParser) GetFlagPos

func (argParser *ArgParser) GetFlagPos(flag string) int

used to scan arguments and detect if command has a special flag

func (*ArgParser) HasFlag

func (argParser *ArgParser) HasFlag(flag string) bool

used to scan arguments and detect if command has a special flag

func (*ArgParser) RemoveFlag

func (argParser *ArgParser) RemoveFlag(flag string) bool

used to scan arguments and detect if command has a special flag

func (*ArgParser) RemoveFlagFromPos

func (argParser *ArgParser) RemoveFlagFromPos(pos int) bool

used to scan arguments and detect if command has a special flag

type CmdDisplay

type CmdDisplay struct {
	GroupName string
}

CmdDisplay is a definition for displaying message for a command line

func NewCmdDisplay

func NewCmdDisplay(groupName string) *CmdDisplay

Initialize a CmdDisplay object ex:

display := NewCmdDisplay("main",true)

func (*CmdDisplay) Debug

func (cmdDisplay *CmdDisplay) Debug(msg string)

Function used to display a debug trace if IsDebug is on

func (*CmdDisplay) Error

func (cmdDisplay *CmdDisplay) Error(msg string)

Function used to display an error

func (*CmdDisplay) ExitError

func (cmdDisplay *CmdDisplay) ExitError(msg string, errorCode int)

Function used to display an error and return exit

func (*CmdDisplay) Info

func (cmdDisplay *CmdDisplay) Info(msg string)

Function used to display an information

func (*CmdDisplay) Warning

func (cmdDisplay *CmdDisplay) Warning(msg string)

Function used to display a warning

Jump to

Keyboard shortcuts

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