Documentation
¶
Index ¶
- Constants
- func CommonPrefix(paths []string, allowRootMatch bool) string
- func DerefSymlink(symlink string) (string, error)
- func EnsureEndsWith(str, suffix string) string
- func ExpandEnv(str string) string
- func GetVerbosity() int
- func Log(level int, message string, color string)
- func LogStdout(message string)
- func ResetLogger()
- func Roots(paths []string, level int, allowRootMatch bool) string
- func SetVerbosity(level int)
- func ShutdownLogger()
- type AbstractCommand
- type Config
- type ExecResult
- type Execution
- type GitTreeWalker
- type Logger
- type Task
- type ThreadPoolManager
- type UserMessage
- type ZoweeOptimizer
Constants ¶
const ( LogQuiet = 0 LogNormal = 1 LogVerbose = 2 LogDebug = 3 )
Verbosity levels
const ( ColorReset = "\033[0m" ColorRed = "\033[31m" ColorGreen = "\033[32m" ColorYellow = "\033[33m" ColorCyan = "\033[36m" )
ANSI color codes
const Version = "0.1.14"
Version is the current version of git-tree-go
Variables ¶
This section is empty.
Functions ¶
func CommonPrefix ¶
CommonPrefix returns the longest path prefix that is a prefix of all paths in the array. If the array is empty, return ”. If only the leading slash matches and allowRootMatch is true, return '/', else return ”.
func DerefSymlink ¶
DerefSymlink returns the real path of a symlink.
func EnsureEndsWith ¶
EnsureEndsWith ensures that a string ends with the specified suffix.
func ExpandEnv ¶
ExpandEnv expands environment variables in a string. Supports $VAR, ${VAR}, and %VAR% formats.
func GetVerbosity ¶
func GetVerbosity() int
GetVerbosity returns the current verbosity level from the default logger.
func ResetLogger ¶ added in v0.1.12
func ResetLogger()
ResetLogger resets the default logger (primarily for testing).
func Roots ¶
Roots returns the common root directory for the given paths up to the specified level. Level is 1-indexed (minimum # of leading directory names in result).
func SetVerbosity ¶
func SetVerbosity(level int)
SetVerbosity sets the verbosity level on the default logger.
Types ¶
type AbstractCommand ¶
AbstractCommand provides common functionality for all git-tree commands.
func NewAbstractCommand ¶
func NewAbstractCommand(args []string, allowEmptyArgs bool) *AbstractCommand
NewAbstractCommand creates a new AbstractCommand instance.
func (*AbstractCommand) ParseCommonFlags ¶
func (cmd *AbstractCommand) ParseCommonFlags(helpFunc func()) []string
ParseCommonFlags parses common flags like -h, -q, -s. Returns the remaining non-flag arguments.
func (*AbstractCommand) ParseFlagsWithCallback ¶
func (cmd *AbstractCommand) ParseFlagsWithCallback(helpFunc func(), callback func(*flag.FlagSet)) []string
ParseFlagsWithCallback parses flags with a custom callback for additional flags. The callback receives a FlagSet to add custom flags.
type Config ¶
type Config struct {
GitTimeout int `yaml:"git_timeout"`
Verbosity int `yaml:"verbosity"`
DefaultRoots []string `yaml:"default_roots"`
}
Config represents the git-tree configuration.
func NewConfig ¶
func NewConfig() *Config
NewConfig creates a new Config with default values. It loads configuration in this order of precedence: 1. Environment variables (GIT_TREE_*) 2. User config file (~/.treeconfig.yml) 3. Default values
func (*Config) SaveToFile ¶
SaveToFile saves the configuration to ~/.treeconfig.yml
type ExecResult ¶
ExecResult captures the result of a command execution.
func RunCommand ¶
func RunCommand(command, dir string) (*ExecResult, error)
RunCommand executes a shell command in a specified directory.
type Execution ¶
type Execution struct {
Command string
Dir string
ExecResult *ExecResult
Error error
}
Execution represents a single command execution.
type GitTreeWalker ¶
type GitTreeWalker struct {
Config *Config
DisplayRoots []string
RootMap map[string][]string
Serial bool
}
GitTreeWalker is used to walk a directory tree and find git repositories.
func NewGitTreeWalker ¶
func NewGitTreeWalker(args []string, serial bool) (*GitTreeWalker, error)
NewGitTreeWalker creates a new GitTreeWalker.
func (*GitTreeWalker) AbbreviatePath ¶
func (w *GitTreeWalker) AbbreviatePath(dir string) string
AbbreviatePath abbreviates a directory path by replacing expanded root prefixes with their original display representations. If a root was specified as an environment variable (e.g., $work), this will condense any path under that root to use the variable name (e.g., /mnt/f/work/foo -> $work/foo).
func (*GitTreeWalker) FindAndProcessRepos ¶
func (w *GitTreeWalker) FindAndProcessRepos(callback func(dir, rootArg string))
FindAndProcessRepos finds git repos and yields them to the callback.
func (*GitTreeWalker) Process ¶
func (w *GitTreeWalker) Process(processFunc func(dir string, threadID int, walker *GitTreeWalker))
Process processes the git repositories using the provided function.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides thread-safe logging with verbosity control and color support.
func (*Logger) GetVerbosity ¶
GetVerbosity returns the current verbosity level.
func (*Logger) SetVerbosity ¶
SetVerbosity sets the verbosity level.
type Task ¶
type Task struct {
History []interface{} // Can contain *Execution or *UserMessage
}
Task remembers all commands that were executed and their results. Also remembers user output.
func (*Task) ExecResultExecution ¶
ExecResultExecution returns the most recent Execution in history.
func (*Task) MessageUser ¶
MessageUser adds a user message to the history if verbosity allows.
func (*Task) MostRecentUserMessage ¶
func (t *Task) MostRecentUserMessage() *UserMessage
MostRecentUserMessage returns the most recent UserMessage in history.
type ThreadPoolManager ¶
type ThreadPoolManager struct {
// contains filtered or unexported fields
}
ThreadPoolManager manages a fixed-size pool of worker goroutines.
func NewThreadPoolManager ¶
func NewThreadPoolManager(percentAvailableProcessors float64) *ThreadPoolManager
NewThreadPoolManager creates a new thread pool manager. percentAvailableProcessors should be between 0 and 1 (e.g., 0.75 for 75%).
func (*ThreadPoolManager) AddTask ¶
func (tp *ThreadPoolManager) AddTask(task interface{})
AddTask adds a task to the work queue.
func (*ThreadPoolManager) Shutdown ¶
func (tp *ThreadPoolManager) Shutdown()
Shutdown signals the pool to shut down gracefully.
func (*ThreadPoolManager) Start ¶
func (tp *ThreadPoolManager) Start(taskFunc func(task interface{}, workerID int))
Start starts the worker pool with the given task function.
func (*ThreadPoolManager) WaitForCompletion ¶
func (tp *ThreadPoolManager) WaitForCompletion()
WaitForCompletion waits for all workers to complete.
type UserMessage ¶
UserMessage represents a message sent to the user.
type ZoweeOptimizer ¶
type ZoweeOptimizer struct {
// contains filtered or unexported fields
}
ZoweeOptimizer optimizes environment variable definitions for git-evars.
func NewZoweeOptimizer ¶
func NewZoweeOptimizer(initialVars map[string][]string) *ZoweeOptimizer
NewZoweeOptimizer creates a new ZoweeOptimizer.