core

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package core provides shared helpers for config subcommands.

Package core provides shared helpers for config subcommands.

It handles profile detection, symlink management, and .ctxrc file resolution used by the config status and switch commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyProfile

func CopyProfile(root, srcFile string) error

CopyProfile copies a source profile file to .ctxrc.

Parameters:

  • root: Git repository root directory
  • srcFile: Source profile filename (e.g., ".ctxrc.dev")

Returns:

  • error: Non-nil on read or write failure

func DetectProfile

func DetectProfile() string

DetectProfile returns the active profile name from the parsed .ctxrc. Returns "" if .ctxrc is missing or has no profile field.

Returns:

  • string: Profile name ("dev", "base", or "")

func GitRoot

func GitRoot() (string, error)

GitRoot returns the git repository root directory.

Returns an error if git is not installed or the current directory is not inside a git repository. Features that depend on git should degrade gracefully when this returns an error.

func SwitchTo

func SwitchTo(root, profile string) (string, error)

SwitchTo copies the requested profile to .ctxrc and returns a status message.

If the requested profile is already active, returns a no-op message. If .ctxrc did not previously exist, returns a "created" message.

Parameters:

  • root: Git repository root directory
  • profile: Target profile name (file.ProfileDev or file.ProfileBase)

Returns:

  • string: Status message for the user
  • error: Non-nil if the profile file copy fails

Types

This section is empty.

Jump to

Keyboard shortcuts

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