project

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package project manages the TOML-backed project registry for ttal.

Projects are stored in ~/.config/ttal/projects.toml (or a per-team variant) as top-level alias sections with name and path fields; archived projects live under [archived]. The Store type provides CRUD and archive/unarchive operations with atomic writes, while resolve.go resolves project paths from taskwarrior project strings.

Plane: shared

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProjectPath added in v1.4.0

func GetProjectPath(alias string) (string, error)

GetProjectPath looks up a project by exact alias and returns its path. Returns a user-friendly error listing available projects if not found. If the alias contains "." and a hierarchical parent exists, suggests it.

func ResolveGitHubToken added in v1.9.0

func ResolveGitHubToken(projectAlias string) string

ResolveGitHubToken returns the GitHub token for a project. Uses hierarchical project name resolution (same as ResolveProjectPath) to find the project's github_token_env field, then calls os.Getenv() to resolve it. Falls back to os.Getenv("GITHUB_TOKEN") if override is not configured or empty.

This uses os.Getenv() — consistent with how all daemon tokens are resolved. The .env file is loaded into the process once at daemon startup; adding new token values to .env requires a daemon restart (same as FORGEJO_TOKEN, etc.). The projects.toml file IS re-read on each call (existing store pattern), so adding/changing github_token_env on a project takes effect immediately.

func ResolveGitHubTokenForTeam added in v1.9.0

func ResolveGitHubTokenForTeam(projectAlias, team string) string

ResolveGitHubTokenForTeam is like ResolveGitHubToken but reads from the specified team's store.

func ResolveProjectPath

func ResolveProjectPath(projectName string) string

ResolveProjectPath looks up a project path by matching the taskwarrior project field against the ttal project alias. Returns empty string if no match found (caller should notify lifecycle agent).

Resolution order:

  1. If projectName matches an alias (with hierarchical fallback: "ttal.pr" → "ttal") → use that project's path
  2. If projectName contains exactly one alias ("ttal-cli" contains "ttal") → use that project's path
  3. If no match but only ONE project exists → use it (single-project shortcut)
  4. Otherwise → return empty (no match)

func ResolveProjectPathForTeam added in v1.3.0

func ResolveProjectPathForTeam(projectName, team string) string

ResolveProjectPathForTeam is like ResolveProjectPath but reads from the specified team's projects.toml instead of the cached active team. Use this when the team is known at call time (e.g. from a CleanupRequest) to avoid sync.Once cache issues in the daemon where config.ResolveProjectsPath() is cached at startup. When team is empty, falls back to ResolveProjectPath behavior.

func ResolveProjectPathOrError added in v1.3.0

func ResolveProjectPathOrError(projectName string) (string, error)

ResolveProjectPathOrError resolves a project path from a taskwarrior project field. Returns a user-friendly error if the project alias is not registered.

func ValidateProjectAlias added in v1.0.0

func ValidateProjectAlias(alias string) error

ValidateProjectAlias checks that a project alias exists (exact match, active only). Returns a user-friendly error listing available projects if not found.

Types

type Project added in v1.0.0

type Project struct {
	Name           string `toml:"name"`
	Path           string `toml:"path"`
	GitHubTokenEnv string `toml:"github_token_env"` // optional: env var name for per-project GitHub token
	Alias          string `toml:"-"`                // derived from TOML key
	Archived       bool   `toml:"-"`                // derived from section
}

Project represents a project entry.

func ResolveProject added in v1.9.0

func ResolveProject(projectName string) *Project

ResolveProject looks up a project by taskwarrior project name using hierarchical resolution. Returns the full Project struct (not just path). Returns nil if no match found.

Resolution order (same as ResolveProjectPath):

  1. Hierarchical candidates: "ttal.pr" → try "ttal.pr", then "ttal"
  2. Contains fallback: "ttal-cli" matches alias "ttal"
  3. Single-project shortcut

func ResolveProjectForTeam added in v1.9.0

func ResolveProjectForTeam(projectName, team string) *Project

ResolveProjectForTeam is like ResolveProject but reads from the specified team's store.

type Store added in v1.0.0

type Store struct {
	// contains filtered or unexported fields
}

Store manages project TOML files.

func NewStore added in v1.0.0

func NewStore(path string) *Store

NewStore creates a store for the given TOML file path.

func (*Store) Add added in v1.0.0

func (s *Store) Add(alias, name, path string) error

Add creates a new project. Returns error if alias already exists.

func (*Store) Archive added in v1.0.0

func (s *Store) Archive(alias string) error

Archive moves a project from active to archived.

func (*Store) Delete added in v1.0.0

func (s *Store) Delete(alias string) error

Delete permanently removes a project from either section.

func (*Store) Exists added in v1.0.0

func (s *Store) Exists(alias string) (bool, error)

Exists checks whether a project alias exists (in either active or archived).

func (*Store) Get added in v1.0.0

func (s *Store) Get(alias string) (*Project, error)

Get returns a project by alias (active only). Returns nil if not found.

func (*Store) List added in v1.0.0

func (s *Store) List(archived bool) ([]Project, error)

List returns all projects. If archived is true, returns only archived; otherwise only active.

func (*Store) Modify added in v1.0.0

func (s *Store) Modify(alias string, updates map[string]string) error

Modify updates fields on an existing active project.

func (*Store) Path added in v1.0.0

func (s *Store) Path() string

Path returns the store file path.

func (*Store) Unarchive added in v1.0.0

func (s *Store) Unarchive(alias string) error

Unarchive moves a project from archived back to active.

Jump to

Keyboard shortcuts

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