Documentation
¶
Overview ¶
internal/compat/builtins.go
internal/compat/detect.go
internal/compat/firstrun.go
internal/compat/import.go
internal/compat/prompt.go
internal/compat/report.go
Index ¶
- func CheckFirstRun() (bool, error)
- func CheckSourceChanged(statePath string) (bool, error)
- func DefaultStatePath() string
- func FormatChangeNotice(rcFile string, skipped int) string
- func FormatHashrcComment(rcFile string) string
- func FormatHashrcCommentFiles(files []string) string
- func FormatImportSummary(report *Report) string
- func FormatWelcomePrompt(shell, rcFile string) string
- func FormatWelcomePromptFiles(files ShellFiles) string
- func IsNoopBuiltin(cmd string) bool
- func NoopBuiltins() map[string]NoopBuiltinFunc
- func ShouldShowMigrationPrompt() (shouldShow bool, previousShell, rcFile string)
- type ImportedItem
- type ItemType
- type NoopBuiltinFunc
- type Report
- type ShellFiles
- type SkippedItem
- type State
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckFirstRun ¶
CheckFirstRun checks if this is the first run using default paths.
func CheckSourceChanged ¶
CheckSourceChanged checks if the source file has changed since last import.
func DefaultStatePath ¶
func DefaultStatePath() string
DefaultStatePath returns the default path for migration state.
func FormatChangeNotice ¶
FormatChangeNotice returns a one-line notice about source file changes.
func FormatHashrcComment ¶
FormatHashrcComment returns the comment block for .hashrc.
func FormatHashrcCommentFiles ¶
FormatHashrcCommentFiles returns the comment block for .hashrc with multiple source files. Note: We don't include source commands here because mvdan/sh's internal source builtin parses with POSIX mode. Instead, Hash sources migration files directly at startup using SourceWithCompat which uses LangBash parsing.
func FormatImportSummary ¶
FormatImportSummary returns a formatted summary of the migration.
func FormatWelcomePrompt ¶
FormatWelcomePrompt returns the welcome message for first-run migration.
func FormatWelcomePromptFiles ¶
func FormatWelcomePromptFiles(files ShellFiles) string
FormatWelcomePromptFiles returns the welcome message showing all detected config files.
func IsNoopBuiltin ¶
IsNoopBuiltin checks if a command is a no-op builtin.
func NoopBuiltins ¶
func NoopBuiltins() map[string]NoopBuiltinFunc
NoopBuiltins returns a map of zsh-specific commands that should be no-ops.
func ShouldShowMigrationPrompt ¶
ShouldShowMigrationPrompt checks if we should show the migration prompt. Returns: shouldShow, previousShell, rcFile
Types ¶
type ImportedItem ¶
type ImportedItem struct {
Type ItemType `json:"type"`
Name string `json:"name"`
Value string `json:"value,omitempty"`
}
ImportedItem represents a successfully imported item.
type NoopBuiltinFunc ¶
NoopBuiltinFunc is a function that handles a no-op builtin. It receives the arguments and a report to log the skip.
type Report ¶
type Report struct {
SourceFile string `json:"source_file"`
SourceShell string `json:"source_shell"`
SourceMtime time.Time `json:"source_mtime"`
ImportTime time.Time `json:"import_time"`
Summary Summary `json:"summary"`
ImportedItems []ImportedItem `json:"imported_items,omitempty"`
SkippedItems []SkippedItem `json:"skipped_items,omitempty"`
}
Report tracks the results of a migration import.
func FilterWithCompat ¶
FilterWithCompat pre-processes a shell config file for compatibility. It returns the filtered content (with zsh-specific commands commented out) and a report of what was processed. The caller should execute the content through their own executor/interpreter.
func SourceWithCompat ¶
SourceWithCompat sources a shell rc file with graceful error handling. It skips zsh-specific builtins and recovers from parse errors. Note: This creates its own interpreter runner, so aliases/functions won't persist to the caller's shell. Use FilterWithCompat + executor for that.
func (*Report) AddImported ¶
AddImported records a successfully imported item.
func (*Report) AddSkipped ¶
AddSkipped records a skipped line.
type ShellFiles ¶
type ShellFiles struct {
Shell string
EnvFile string // Environment file sourced for all invocations (e.g., .zshenv)
ProfileFile string // Login shell config (e.g., .zprofile, .bash_profile)
RCFile string // Interactive shell config (e.g., .zshrc, .bashrc)
}
ShellFiles contains the config files for a shell.
func DetectPreviousShellFiles ¶
func DetectPreviousShellFiles() ShellFiles
DetectPreviousShellFiles detects the user's previous shell and all its config files.
func (ShellFiles) Files ¶
func (sf ShellFiles) Files() []string
Files returns a slice of existing files in source order (env first, then profile, then rc).
type SkippedItem ¶
type SkippedItem struct {
Line int `json:"line"`
Content string `json:"content"`
Reason string `json:"reason"`
}
SkippedItem represents a line that was skipped during import.
type State ¶
type State struct {
SourceFile string `json:"source_file"`
SourceFiles []string `json:"source_files,omitempty"` // Individual file paths for sourcing
SourceShell string `json:"source_shell"`
SourceMtime time.Time `json:"source_mtime"`
LastImport time.Time `json:"last_import"`
Declined bool `json:"declined"`
Summary Summary `json:"summary"`
}
State represents the persisted migration state.