workdir

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package workdir does best-effort detection of the "primary working directory" that a coily invocation is operating against. Subcommands

Index

Constants

View Source
const OverrideEnv = "COILY_PRIMARY_DIR"

OverrideEnv names the env var that forces Detect's answer.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Path   string
	Source Source
}

Result is what Detect returns. Path is always absolute and cleaned.

func Detect

func Detect() Result

Detect runs the signal chain against the current process cwd.

func DetectFrom

func DetectFrom(cwd string) Result

DetectFrom is Detect parameterized on cwd, for tests and callers that already have a working directory in hand.

type Source

type Source string

Source labels which signal produced the result. Callers that need to gate behavior on confidence should branch on this.

const (
	// SourceEnv means $COILY_PRIMARY_DIR forced the answer.
	SourceEnv Source = "env"
	// SourceGit means the nearest ancestor with a .git entry won.
	SourceGit Source = "git"
	// SourceCoilysiren means the first path segment under
	// ~/projects/coilysiren/ won.
	SourceCoilysiren Source = "coilysiren"
	// SourceCWD means no other signal matched and cwd was returned verbatim.
	SourceCWD Source = "cwd"
)

Signal labels for Result.Source, in detection-precedence order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL