utils

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Other textEncoding = iota
	UTF8
	UTF16LE
	UTF16BE
	UTF32LE
	UTF32BE
)
View Source
const AnnotationsFileName = ".annotations.json"
View Source
const DotEnvFileName = ".env"
View Source
const StashesDirName = ".stash"

Variables

This section is empty.

Functions

func AppendToTextFile

func AppendToTextFile(filePath string, text string) error

func CalculateSHA256

func CalculateSHA256(filePath string) (string, error)

func CaseInsensitiveFileSearch

func CaseInsensitiveFileSearch(targetFile string, fileNames []string) (string, bool)

func CaseInsensitiveLeadingDirectoriesSearch

func CaseInsensitiveLeadingDirectoriesSearch(targetFile string, projectFileNames []string) []string

func CheckFilenameCaseCollisions

func CheckFilenameCaseCollisions(fileNames []string) bool

func CheckForPathSeparatorsInFilenames

func CheckForPathSeparatorsInFilenames(fileNames []string) bool

func ConvertFilePathToOSFormat

func ConvertFilePathToOSFormat(targetFile string) string

func FilterRequestedProjectFiles added in v1.7.1

func FilterRequestedProjectFiles(projectRootDir string, llmRequestedFiles []string, userRequestedFiles []string, projectFiles []string, logger logging.ILogger) []string

func FindConfigDir added in v1.7.1

func FindConfigDir() (string, error)

func FindInFile

func FindInFile(filePath string, regexps []*regexp.Regexp) (bool, error)

func FindInRelativeFile added in v1.7.1

func FindInRelativeFile(projectRootDir string, relativeFilePath string, regexps []*regexp.Regexp) (bool, error)

func FindProjectRoot

func FindProjectRoot(logger logging.ILogger) (string, string, error)

func GetAnnotations

func GetAnnotations(filePath string, fileChecksums map[string]string) (map[string]string, error)

func GetChangedFiles

func GetChangedFiles(filePath string, fileChecksums map[string]string) ([]string, error)

func GetEnvFloat added in v1.4.1

func GetEnvFloat(vars ...string) (float64, error)

func GetEnvInt added in v1.4.1

func GetEnvInt(vars ...string) (int, error)

func GetEnvString added in v1.4.1

func GetEnvString(vars ...string) (string, error)

func GetEnvUpperString added in v1.4.1

func GetEnvUpperString(vars ...string) (string, error)

func GetProjectFileList

func GetProjectFileList(projectRootDir string, perpetualDir string, projectFilesWhitelist []string, projectFilesBlacklist []string) (map[string]string, []string, []string, error)

Recursively get project files, starting from projectRootDir Return values: - map with checksums of files filtered with whitelist and blacklist - filenames filtered with whitelist and blacklist (relative to projectRootDir) - all filenames processed (relative to projectRootDir) - error, if any

func GetTextAfterFirstMatch

func GetTextAfterFirstMatch(text, searchRegexp string) (string, error)

func GetTextAfterFirstMatches added in v1.4.1

func GetTextAfterFirstMatches(text string, searchRegexps []string) (string, error)

func GetTextBeforeLastMatch

func GetTextBeforeLastMatch(text, searchRegexp string) (string, error)

func GetTextBeforeLastMatches added in v1.4.1

func GetTextBeforeLastMatches(text string, searchRegexps []string) (string, error)

func LoadEnvFiles added in v1.7.1

func LoadEnvFiles(logger logging.ILogger, filePaths ...string)

func LoadJsonFile

func LoadJsonFile(filePath string, v any) error

func LoadStringPair added in v1.4.1

func LoadStringPair(file string, minLen int, maxLen int, lenDivideBy int, logger logging.ILogger) []string

func LoadTextFile

func LoadTextFile(filePath string) (string, error)

func MakePathRelative

func MakePathRelative(basePath string, filePath string, cdIntoBasePath bool) (string, error)

func ParseMultiTaggedText added in v1.4.1

func ParseMultiTaggedText(sourceText string, startTagRegexps []string, endTagRegexps []string, ignoreUnclosedTagErrors bool) ([]string, error)

Parse text enclosed with multiple start and end tags provided as regexps.

func ParseTaggedText

func ParseTaggedText(sourceText string, startTagRegexp string, endTagRegexp string, ignoreUnclosedTagErrors bool) ([]string, error)

Parse text enclosed with start and end tags provided as regexps.

func ReplaceTag

func ReplaceTag(text, searchRegex, replacement string) (string, error)

Search and replace all matches of searchRegex in the text Please, consider not to use it on big texts.

func SaveAnnotations

func SaveAnnotations(filePath string, checksums map[string]string, annotations map[string]string) error

func SaveJsonFile

func SaveJsonFile(filePath string, v any) error

func SaveTextFile

func SaveTextFile(filePath string, text string) error

Types

type AnnotationEntries

type AnnotationEntries []AnnotationEntry

func (AnnotationEntries) Len

func (entries AnnotationEntries) Len() int

func (AnnotationEntries) Less

func (entries AnnotationEntries) Less(i, j int) bool

func (AnnotationEntries) Swap

func (entries AnnotationEntries) Swap(i, j int)

type AnnotationEntry

type AnnotationEntry struct {
	Filename   string `json:"filename"`
	Checksum   string `json:"checksum"`
	Annotation string `json:"annotation"`
}

Jump to

Keyboard shortcuts

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