Documentation
¶
Index ¶
- Constants
- Variables
- func CreateDirectories(dirs ...string) error
- func CreateFiles(files ...string) error
- func DetachFromTerminal(cmd *exec.Cmd)
- func DirSize(path string) int64
- func ExecuteCommand(timeLimit time.Duration, cmdDir string, baseCmd string, args ...string) (int, string, error)
- func ExecuteCommandInShell(timeLimit time.Duration, cmdDir string, shellCommand string) (int, string, error)
- func FullFooterHeight(footerHeight int, toggleFooter bool) int
- func FzfSearch(query string, source []string) []fzf.MatchResult
- func InitJSONFile(path string) error
- func LoadTomlFile(filePath string, defaultData string, target interface{}, fixFlag bool, ...) error
- func PrintfAndExitf(format string, args ...any)
- func PrintlnAndExit(args ...any)
- func ReadBoolFile(path string, defaultValue bool) bool
- func ReadFileContent(filepath string, maxLineLength int, previewLine int) (string, error)
- func ResolveAbsPath(currentDir string, path string) string
- func SetRootLoggerToDiscarded()
- func SetRootLoggerToStdout(debug bool)
- func SetupDirectories(t *testing.T, dirs ...string)
- func SetupFiles(t *testing.T, files ...string)
- func SetupFilesWithData(t *testing.T, data []byte, files ...string)
- func TeaRuneKeyMsg(msg string) tea.KeyMsg
- func WriteBoolFile(path string, value bool) error
- func WriteTomlData(filePath string, data interface{}) error
- type MissingFieldIgnorer
- type TestTOMLMissingIgnorerType
- type TestTOMLType
- type TomlLoadError
Constants ¶
const ( TrueString = "true" FalseString = "false" // These are used while comparing with runtime.GOOS // OsWindows represents the Windows operating system identifier OsWindows = "windows" // OsDarwin represents the macOS (Darwin) operating system identifier OsDarwin = "darwin" OsLinux = "linux" // File permissions ConfigFilePerm = 0600 // configuration files (owner read/write only) UserFilePerm = 0644 // user-created files (owner rw, others r) LogFilePerm = 0600 // log files (owner read/write only) // Directory permissions ConfigDirPerm = 0700 // configuration directories (owner only) UserDirPerm = 0755 // user-created directories (owner rwx, others rx) // Extracted file permissions (from archives) ExtractedFileMode = 0644 // extracted files ExtractedDirMode = 0755 // extracted directories )
Variables ¶
var SampleDataBytes = []byte("This is sample") //nolint: gochecknoglobals // Effectively const
Functions ¶
func CreateDirectories ¶ added in v1.4.0
Helper functions Create all dirs that does not already exists
func CreateFiles ¶ added in v1.4.0
Create all files if they do not exists yet
func DetachFromTerminal ¶ added in v1.4.0
func ExecuteCommand ¶
func ExecuteCommandInShell ¶
func ExecuteCommandInShell(timeLimit time.Duration, cmdDir string, shellCommand string) (int, string, error)
Choose correct shell as per OS
func FullFooterHeight ¶
Including borders
func FzfSearch ¶
func FzfSearch(query string, source []string) []fzf.MatchResult
Returning a string slice causes inefficiency in current usage
func InitJSONFile ¶ added in v1.5.0
func LoadTomlFile ¶
func LoadTomlFile(filePath string, defaultData string, target interface{}, fixFlag bool, ignoreMissingFields bool) error
Helper function to load and validate TOML files with field checking errorPrefix is appended before every error message
func PrintfAndExitf ¶ added in v1.5.0
Print formatted output line to stderr and exit with status 1 Cannot use log.Fataln() as slog.SetDefault() causes those lines to go into log file
func PrintlnAndExit ¶
func PrintlnAndExit(args ...any)
Print line to stderr and exit with status 1 Cannot use log.Fataln() as slog.SetDefault() causes those lines to go into log file
func ReadBoolFile ¶
Read file with "true" / "false" as content. In case of issues, return defaultValue
func ReadFileContent ¶ added in v1.4.0
func ResolveAbsPath ¶
If path is not absolute, then append to currentDir and get absolute path Resolve paths starting with "~" currentDir should be an absolute path
func SetupDirectories ¶ added in v1.4.0
func SetupFiles ¶ added in v1.4.0
func SetupFilesWithData ¶ added in v1.4.0
func TeaRuneKeyMsg ¶
func WriteBoolFile ¶
func WriteTomlData ¶
Utility functions related to file operations Note : This is not used anymore as we use os.WriteAt to fix toml files now, but we will still keep it for later use.
Types ¶
type MissingFieldIgnorer ¶ added in v1.3.2
type MissingFieldIgnorer interface {
GetIgnoreMissingFields() bool
}
MissingFieldIgnorer defines the interface for configuration types that can ignore missing fields during TOML file loading. Types implementing this interface can control whether missing field warnings are suppressed when parsing configuration files.
type TestTOMLMissingIgnorerType ¶ added in v1.3.2
type TestTOMLMissingIgnorerType struct {
SampleBool bool `toml:"sample_bool"`
SampleInt int `toml:"sample_int"`
SampleStr string `toml:"sample_str"`
SampleSlice []string `toml:"sample_slice"`
IgnoreMissing bool `toml:"ignore_missing"`
}
func (TestTOMLMissingIgnorerType) GetIgnoreMissingFields ¶ added in v1.3.2
func (t TestTOMLMissingIgnorerType) GetIgnoreMissingFields() bool
func (TestTOMLMissingIgnorerType) WithIgnoreMissing ¶ added in v1.3.2
func (t TestTOMLMissingIgnorerType) WithIgnoreMissing(val bool) TestTOMLMissingIgnorerType
type TestTOMLType ¶ added in v1.3.2
type TomlLoadError ¶ added in v1.3.2
type TomlLoadError struct {
// contains filtered or unexported fields
}
func (*TomlLoadError) AddMessageAndError ¶ added in v1.3.2
func (t *TomlLoadError) AddMessageAndError(msg string, err error)
Include another msg. For now we dont need to have this as wrapped error.
func (*TomlLoadError) Error ¶ added in v1.3.2
func (t *TomlLoadError) Error() string
func (*TomlLoadError) IsFatal ¶ added in v1.3.2
func (t *TomlLoadError) IsFatal() bool
func (*TomlLoadError) MissingFields ¶ added in v1.3.2
func (t *TomlLoadError) MissingFields() bool
func (*TomlLoadError) Unwrap ¶ added in v1.3.2
func (t *TomlLoadError) Unwrap() error
func (*TomlLoadError) UpdateMessageAndError ¶ added in v1.3.2
func (t *TomlLoadError) UpdateMessageAndError(msg string, err error)