Documentation
¶
Overview ¶
Package clitool installs the gadak binary onto PATH via a symlink. Shared by `gadak install-cli` and the desktop "Install Command Line Tool…" menu so both surfaces use the same resolve / install / PATH-advice logic.
Index ¶
- Constants
- func DefaultDir(pathEnv string) (string, error)
- func ExpandHome(p string) (string, error)
- func Install(p Plan, force bool) error
- func PathContains(pathEnv, dir string) bool
- func PathExportAdvise(dir, shell string) (line, rc string)
- func PathExportLine(dir, shell string) string
- func ResolveDir(dirFlag, pathEnv string) (string, error)
- func TildeHome(path string) string
- type Plan
Constants ¶
const ( StatusMissing = "missing" // nothing at Dest StatusLinked = "linked" // Dest is already a symlink to Source StatusConflict = "conflict" // Dest exists but is not the desired link )
Destination status after Resolve.
Variables ¶
This section is empty.
Functions ¶
func DefaultDir ¶
DefaultDir chooses an install directory when --dir is omitted.
Order (see comment block in the body):
- ~/.local/bin if it exists and is already on PATH
- /usr/local/bin if it is on PATH and writable without sudo
- ~/.local/bin otherwise (create on Install; caller may warn about PATH)
func ExpandHome ¶
ExpandHome expands a leading ~ or ~/… using os.UserHomeDir. Other paths are returned cleaned as-is.
func Install ¶
Install creates Dir if needed and symlinks Dest → Source. When Status is linked, Install is a no-op. When Status is conflict and force is false, Install returns an error without touching the filesystem. force replaces an existing Dest.
func PathContains ¶
PathContains reports whether dir appears as a PATH entry (exact, after Clean). Empty entries are ignored. Leading ~ in pathEnv entries is expanded.
func PathExportAdvise ¶
PathExportAdvise returns a pasteable one-liner and a suggested shell rc path for persistence (rc may be empty).
func PathExportLine ¶
PathExportLine returns a one-liner the user can paste to add dir to PATH (clipboard / advisory). shell is typically os.Getenv("SHELL").
func ResolveDir ¶
ResolveDir returns the absolute install directory. Empty flag → DefaultDir(pathEnv). Leading ~ is expanded.
Types ¶
type Plan ¶
type Plan struct {
Source string
Dir string
Dest string
// Status is one of StatusMissing, StatusLinked, StatusConflict.
Status string
OnPath bool
// ExistingKind / ExistingTarget describe a conflict (or the current link).
// Kind is "symlink", "file", "directory", or "other".
ExistingKind string
ExistingTarget string // absolute path for symlinks; empty otherwise
}
Plan is the result of Resolve: where to install, what is there, and whether the install directory is already on PATH.