appctx

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindGitRoot

func FindGitRoot(ctx context.Context, start string) string

findGitRoot attempts to use the git CLI to determine the repository top-level directory starting from 'start'. If that fails (git not available, not a git worktree, or command error), it falls back to the original upward filesystem search for a .git entry.

Types

type AppContext

type AppContext struct {
	Appname string

	// Root is the path to the root of the context.
	Root string

	// configRoot is the base directory for user configuration files.
	ConfigRoot string

	// stateRoot holds transient state files for the context.
	StateRoot string

	// dataRoot is for programmatically managed data shipped with the program.
	DataRoot string

	// cacheRoot is for cache artifacts.
	CacheRoot string

	// localConfigRoot is the repo-local override location
	LocalConfigRoot string
}

AppContext holds paths and configuration roots for a repository-backed app context. Root is the repository root. Other roots default to platform user-scoped locations when not provided.

func NewAppContext

func NewAppContext(ctx context.Context, appname string) (*AppContext, error)

NewAppContext constructs a app context and fills missing roots using platform defaults derived from the provided context.

Behavior:

  • If an option sets a value it is used as-is.
  • If Root is not set it is inferred from Env.Getwd().
  • ConfigRoot, DataRoot, StateRoot and CacheRoot use the corresponding user-scoped platform paths and are joined with DefaultAppName.

func NewGitAppContext

func NewGitAppContext(ctx context.Context, appname string) (*AppContext, error)

Jump to

Keyboard shortcuts

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