common_types

package
v0.0.0-...-8b68c8a Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: GPL-3.0 Imports: 9 Imported by: 13

Documentation

Index

Constants

View Source
const (
	// AppNameUndefined - default NameApp value, don't use it
	AppNameUndefined NameApp = ""

	// InfoChapterNAMEUndefined - default InfoChapterNAME value, don't use it
	InfoChapterNAMEUndefined InfoChapterNAME = ""

	// InfoChapterDESCRIPTIONUndefined - default InfoChapterDESCRIPTION value, don't use it
	InfoChapterDESCRIPTIONUndefined InfoChapterDESCRIPTION = ""

	// NamePlaceholderUndefined - default NamePlaceholder value, don't use it
	NamePlaceholderUndefined NamePlaceholder = ""

	// ArgPlaceholderIDUndefined - default IDPlaceholder value, don't use it
	ArgPlaceholderIDUndefined IDPlaceholder = 0

	// NameArgHelpUndefined - default NameArgHelp value, don't use it
	NameArgHelpUndefined NameArgHelp = ""
)
View Source
const (
	// LenNameArgHelpMin - min NameArgHelp length
	LenNameArgHelpMin = 2

	// LenNameArgHelpMax - max NameArgHelp length
	LenNameArgHelpMax = 5
)
View Source
const (
	// LenNameCommandMin - min len of NameCommand
	LenNameCommandMin size.Width = 3

	// LenNameCommandMax - max len of NameCommand
	LenNameCommandMax size.Width = 12
)
View Source
const (
	// NameFlagUndefined - default NameFlag value, don't use it
	NameFlagUndefined NameFlag = ""

	// LenNameFlagWithOneDashMax - max amount characters in NameFlag which is like "-f"
	LenNameFlagWithOneDashMax = 3

	// LenNameFlagWithTwoDashesMax - max amount characters in NameFlag which is like "--flag"
	LenNameFlagWithTwoDashesMax = 12
)

Variables

View Source
var (
	// ErrNameArgHelpTooShort - NameArgHelp is too short
	ErrNameArgHelpTooShort = errors.New(`NameArgHelp: too short`)

	// ErrNameArgHelpTooLong - NameArgHelp is too long
	ErrNameArgHelpTooLong = errors.New(`NameArgHelp: too long`)
)
View Source
var (
	// ErrNameCommandDashInFront - unexpected dash in front
	ErrNameCommandDashInFront = fmt.Errorf("NameCommand: must not have dash in front; exceptions are '%s' and '%s' for help command", NameCommandHelpDashHException, NameCommandHelpDashHelpException)

	// ErrNameCommandEmpty - empty string
	ErrNameCommandEmpty = errors.New("NameCommand: is empty")

	// ErrNameCommandHelpCommandTooShort - len is less than LenNameCommandMin
	ErrNameCommandHelpCommandTooShort = errors.New("NameCommand: help command is too short; exception '-h'")

	// ErrNameCommandTooLong - len is more than LenNameCommandMax
	ErrNameCommandTooLong = errors.New("NameCommand: is too long")

	// ErrNameCommandTooShort - len is less than LenNameCommandMin
	ErrNameCommandTooShort = errors.New("NameCommand: is too short")

	// ErrNameCommandUnexpectedChar - NameCommand has unexpected char
	ErrNameCommandUnexpectedChar = errors.New("NameCommand: unexpected character")
)
View Source
var (
	// ErrNameFlagIsValidEmpty - NameFlag is empty string
	ErrNameFlagIsValidEmpty = errors.New(`common_types: NameFlag.IsValid: is empty`)

	// ErrNameFlagIsValidNoDashInFront - NameFlag must have dash in front
	ErrNameFlagIsValidNoDashInFront = errors.New(`common_types: NameFlag.IsValid: flag must have dash in front`)

	// ErrNameFlagIsValidTooLong - NameFlag len is more than LenNameFlagWithTwoDashesMax
	ErrNameFlagIsValidTooLong = errors.New(`common_types: NameFlag.IsValid: too long`)

	// ErrNameFlagIsValidTooManyDashesInFront - NameFlag has three or more dashes in front
	ErrNameFlagIsValidTooManyDashesInFront = errors.New(`common_types: NameFlag.IsValid: flag must have only one ore two dashes in front`)

	// ErrNameFlagIsValidTooShort - NameFlag len is too short
	ErrNameFlagIsValidTooShort = errors.New(`common_types: NameFlag.IsValid: too short`)

	// ErrNameFlagIsValidUnexpectedChar - NameFlag has unexpected char
	ErrNameFlagIsValidUnexpectedChar = errors.New(`common_types: NameFlag.IsValid: unexpected character`)
)

Functions

func RandError

func RandError() error

RandError returns random error

func RandErrorFifth

func RandErrorFifth() error

RandErrorFifth random error

func RandErrorFourth

func RandErrorFourth() error

RandErrorFourth random error

func RandErrorSecond

func RandErrorSecond() error

RandErrorSecond random error

func RandErrorThird

func RandErrorThird() error

RandErrorThird random error

func SortSlice

func SortSlice[T constraints.Ordered](s []T)

SortSlice sorts slice of alias types

func ToSliceStrings

func ToSliceStrings[T fmt.Stringer](from []T) []string

ToSliceStrings converts []T to []string

func ToSliceTypesSorted

func ToSliceTypesSorted[T constraintsToSlice](from []string) []T

ToSliceTypesSorted converts string slice to T slice

Types

type ArgValue

type ArgValue string

ArgValue - value of argument as string

func (ArgValue) String

func (n ArgValue) String() string

String implements Stringer interface

type IDPlaceholder

type IDPlaceholder uint8

IDPlaceholder - flag/argument placeholder id

func RandIDPlaceholder

func RandIDPlaceholder() IDPlaceholder

RandIDPlaceholder returns random IDPlaceholder

func RandIDPlaceholderSecond

func RandIDPlaceholderSecond() IDPlaceholder

RandIDPlaceholderSecond returns random IDPlaceholder

func RandIDPlaceholderThird

func RandIDPlaceholderThird() IDPlaceholder

RandIDPlaceholderThird returns random IDPlaceholder

type InfoChapterDESCRIPTION

type InfoChapterDESCRIPTION string

InfoChapterDESCRIPTION - string with information for DESCRIPTION chapter

func RandInfoChapterDescription

func RandInfoChapterDescription() InfoChapterDESCRIPTION

RandInfoChapterDescription returns random InfoChapterDESCRIPTION

func RandInfoChapterDescriptionSecond

func RandInfoChapterDescriptionSecond() InfoChapterDESCRIPTION

RandInfoChapterDescriptionSecond returns random InfoChapterDESCRIPTION

func (InfoChapterDESCRIPTION) String

func (i InfoChapterDESCRIPTION) String() string

String implements Stringer interface

type InfoChapterNAME

type InfoChapterNAME string

InfoChapterNAME - string with information for NAME chapter

func RandInfoChapterName

func RandInfoChapterName() InfoChapterNAME

RandInfoChapterName returns random InfoChapterNAME

func (InfoChapterNAME) String

func (i InfoChapterNAME) String() string

String implements Stringer interface

type NameApp

type NameApp string

NameApp - string with application name

func RandNameApp

func RandNameApp() NameApp

RandNameApp returns random NameApp

func (NameApp) String

func (n NameApp) String() string

String implements Stringer interface

type NameArgHelp

type NameArgHelp string

NameArgHelp - name of argument for create help page

func (NameArgHelp) IsValid

func (n NameArgHelp) IsValid() error

IsValid checks if NameArgHelp is valid

func (NameArgHelp) String

func (n NameArgHelp) String() string

String implements Stringer interface

type NameCommand

type NameCommand string

NameCommand - name type of command

const (
	// NameCommandUndefined - default NameCommand value, nameless command has this name
	NameCommandUndefined NameCommand = ""

	// NameCommandHelpHException - exception name for 'h' command name
	NameCommandHelpHException NameCommand = "h"

	// NameCommandHelpDashHException - exception name for '-h' command name
	NameCommandHelpDashHException NameCommand = "-h"

	// NameCommandHelpDashHelpException - exception name for '--help' command name
	NameCommandHelpDashHelpException NameCommand = "--help"
)

func RandNameCommand

func RandNameCommand() NameCommand

RandNameCommand returns random NameCommand

func RandNameCommandFifth

func RandNameCommandFifth() NameCommand

RandNameCommandFifth returns random NameCommand

func RandNameCommandFourth

func RandNameCommandFourth() NameCommand

RandNameCommandFourth returns random NameCommand

func RandNameCommandLong

func RandNameCommandLong() NameCommand

RandNameCommandLong returns random long command name

func RandNameCommandSecond

func RandNameCommandSecond() NameCommand

RandNameCommandSecond returns random NameCommand

func RandNameCommandShort

func RandNameCommandShort() NameCommand

RandNameCommandShort returns random short command name

func RandNameCommandShortSecond

func RandNameCommandShortSecond() NameCommand

RandNameCommandShortSecond returns random short command name

func RandNameCommandThird

func RandNameCommandThird() NameCommand

RandNameCommandThird returns random NameCommand

func RandNameCommandTooLong

func RandNameCommandTooLong() NameCommand

RandNameCommandTooLong returns random invalid too long command name

func RandNameCommandTooShort

func RandNameCommandTooShort() NameCommand

RandNameCommandTooShort returns random invalid too short command name

func (NameCommand) IsValid

func (n NameCommand) IsValid(thisIsHelpCommand bool) error

IsValid checks if NameCommand doesn't have dash in front, isn't too short/long

func (NameCommand) String

func (n NameCommand) String() string

String implements Stringer interface

type NameFlag

type NameFlag string

NameFlag - name type of command flag

func RandNameFlagLong

func RandNameFlagLong() NameFlag

RandNameFlagLong returns random NameFlag like '--name-flag'

func RandNameFlagOneLetter

func RandNameFlagOneLetter() NameFlag

RandNameFlagOneLetter returns random NameFlag like '-f'

func RandNameFlagShort

func RandNameFlagShort() NameFlag

RandNameFlagShort returns random NameFlag like '-fg'

func RandNameFlagShortSecond

func RandNameFlagShortSecond() NameFlag

RandNameFlagShortSecond returns random NameFlag like '-fg'

func RandNameFlagShortThird

func RandNameFlagShortThird() NameFlag

RandNameFlagShortThird returns random NameFlag like '-fg'

func (NameFlag) IsDoubleDash

func (n NameFlag) IsDoubleDash() bool

IsDoubleDash returns if NameFlag has double dash prefix

func (NameFlag) IsValid

func (n NameFlag) IsValid() error

IsValid checks if NameFlag has dash in front and is not too long

func (NameFlag) String

func (n NameFlag) String() string

String implements Stringer interface

type NamePlaceholder

type NamePlaceholder string

NamePlaceholder - flag/argument placeholder string id

func RandNamePlaceholder

func RandNamePlaceholder() NamePlaceholder

RandNamePlaceholder returns random NamePlaceholder

func RandNamePlaceholderSecond

func RandNamePlaceholderSecond() NamePlaceholder

RandNamePlaceholderSecond returns random NamePlaceholder

func (NamePlaceholder) String

func (n NamePlaceholder) String() string

String implements Stringer interface

Jump to

Keyboard shortcuts

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