Documentation
¶
Index ¶
- Variables
- func AppendInit(rcPath string, shell Shell) error
- func CompletionFilePath(shell Shell, homeDir string) string
- func EvalCondition(expr string, ctx *ConditionContext) (bool, error)
- func InitLine(shell Shell) string
- func IsInitPresent(rcPath string) (bool, error)
- func Render(shell Shell, funcs []ShellFunc, cr CompletionRenderer) string
- func WriteCompletionFile(shell Shell, homeDir string, content string) (string, error)
- type CmdExecutor
- type CompletionRenderer
- type CompletionStatus
- type ConditionContext
- type EnvFileHandler
- type PackageManager
- type RCFileManager
- type RealCmdExecutor
- type Runner
- type Shell
- type ShellDetector
- type ShellFunc
Constants ¶
This section is empty.
Variables ¶
var DefaultEnvFiles = []string{".env", ".env.local", ".env.development", ".env.development.local"}
DefaultEnvFiles is the default list of env files to handle.
Functions ¶
func AppendInit ¶
AppendInit appends the wtf init line to the RC file.
func CompletionFilePath ¶ added in v0.4.0
CompletionFilePath returns the standard user-local completion file path for the given shell.
func EvalCondition ¶ added in v0.4.0
func EvalCondition(expr string, ctx *ConditionContext) (bool, error)
EvalCondition evaluates a condition expression. Supported forms:
- "" (empty) → true
- "branch contains '<value>'"
- "file exists '<path>'"
- "env VAR is set"
func InitLine ¶
InitLine returns the eval line for the given shell. Uses explicit shell argument like Starship: eval "$(wtf init bash)"
func IsInitPresent ¶
IsInitPresent checks whether the wtf init line is already in the file.
Types ¶
type CmdExecutor ¶ added in v0.4.0
type CmdExecutor interface {
RunShell(dir, command string) error
RunInteractive(dir, command string) error
}
CmdExecutor abstracts shell command execution for testability.
type CompletionRenderer ¶ added in v0.4.0
CompletionRenderer generates a shell completion script for the given shell. Used by Render to optionally append tab-completion support.
type CompletionStatus ¶ added in v0.4.0
type CompletionStatus struct {
Configured bool
Method string // "inline", "file", ""
Path string // file path if method is "file"
}
CompletionStatus represents whether completions are configured for a shell.
func IsCompletionConfigured ¶ added in v0.4.0
func IsCompletionConfigured(shell Shell, rcPath string, homeDir string) (CompletionStatus, error)
IsCompletionConfigured checks if wtf completions are set up for the given shell. It checks two sources: the RC file (inline via "wtf init") and standard completion file locations.
type ConditionContext ¶ added in v0.4.0
ConditionContext provides context for condition evaluation.
type EnvFileHandler ¶ added in v0.4.0
type EnvFileHandler struct {
Symlink func(oldname, newname string) error
CopyFile func(src, dst string) error
}
EnvFileHandler handles env file operations with injectable functions.
func NewEnvFileHandler ¶ added in v0.4.0
func NewEnvFileHandler() *EnvFileHandler
NewEnvFileHandler creates an EnvFileHandler with real OS functions.
func (*EnvFileHandler) HandleEnvFiles ¶ added in v0.4.0
func (h *EnvFileHandler) HandleEnvFiles(mainDir, targetDir, strategy string, files []string) error
HandleEnvFiles processes env files according to the strategy.
type PackageManager ¶ added in v0.4.0
PackageManager describes a detected package manager.
func DetectPackageManager ¶ added in v0.4.0
func DetectPackageManager(dir string) (*PackageManager, error)
DetectPackageManager detects the package manager from lockfiles in dir. Returns nil, nil if no known lockfile is found.
type RCFileManager ¶
type RCFileManager struct {
HomeDir string
}
RCFileManager handles shell RC file operations.
func NewRCFileManager ¶
func NewRCFileManager() (*RCFileManager, error)
NewRCFileManager returns an RCFileManager using the real home directory.
func (*RCFileManager) RCFilePath ¶
func (m *RCFileManager) RCFilePath(shell Shell) (string, error)
RCFilePath returns the RC file path for the given shell.
type RealCmdExecutor ¶ added in v0.4.0
type RealCmdExecutor struct{}
RealCmdExecutor executes shell commands via /bin/sh.
func (*RealCmdExecutor) RunInteractive ¶ added in v0.4.0
func (r *RealCmdExecutor) RunInteractive(dir, command string) error
RunInteractive executes a command with full terminal access (stdin/stdout/stderr). Uses the user's login shell with -ic so aliases and shell functions are available.
func (*RealCmdExecutor) RunShell ¶ added in v0.4.0
func (r *RealCmdExecutor) RunShell(dir, command string) error
RunShell executes a command string via /bin/sh in the given directory. When stdout is a terminal, output is displayed in a fixed-height scrolling region so long builds don't flood the screen.
type Runner ¶ added in v0.4.0
type Runner struct {
CmdExec CmdExecutor
EnvHandler *EnvFileHandler
}
Runner orchestrates project setup.
func NewRunner ¶ added in v0.4.0
func NewRunner() *Runner
NewRunner creates a Runner with real implementations.
func (*Runner) RunHooks ¶ added in v0.4.0
RunHooks runs a list of hook commands in the given directory. Hooks run interactively with full terminal access, bypassing the scroll writer.
func (*Runner) RunSetup ¶ added in v0.4.0
func (r *Runner) RunSetup(cfg *config.ProjectConfig, mainDir, targetDir, branch string) error
RunSetup runs the full setup flow for a worktree. If cfg is nil, auto-detect package manager and run install if found. If cfg exists: handle env files → auto-detect + run install → evaluate & run setup steps → run hooks.
type Shell ¶
type Shell string
Shell represents a supported shell type.
func ParseShellName ¶ added in v0.4.0
ParseShellName parses a shell name string into a Shell type.
type ShellDetector ¶
type ShellDetector struct {
// GetEnv returns the value of an environment variable.
GetEnv func(string) string
// ReadParentComm reads the parent process comm file (e.g. /proc/<pid>/comm).
ReadParentComm func(pid int) (string, error)
}
ShellDetector detects the user's current shell.
func NewShellDetector ¶
func NewShellDetector() *ShellDetector
NewShellDetector returns a ShellDetector using real OS functions.