setup

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbbreviatePath

func AbbreviatePath(path string) string

AbbreviatePath replaces the home directory with ~ for display

func GetOrCreateNode

func GetOrCreateNode(root *yaml.Node, path ...string) *yaml.Node

GetOrCreateNode traverses the YAML tree and returns or creates a node at the given path. If any intermediate keys don't exist, they are created as mapping nodes.

func GetValue

func GetValue(root *yaml.Node, path ...string) string

GetValue retrieves a string value from the YAML tree at the specified path. Returns empty string if not found.

func GlobalConfigPath

func GlobalConfigPath() string

GlobalConfigPath returns the path to the global grove configuration file.

func GlobalTOMLConfigPath added in v0.6.2

func GlobalTOMLConfigPath() string

GlobalTOMLConfigPath returns the path to the global grove TOML configuration file.

func HasKey

func HasKey(root *yaml.Node, path ...string) bool

HasKey checks if a key exists at the specified path

func SetValue

func SetValue(root *yaml.Node, value interface{}, path ...string) error

SetValue sets a value at the specified path in the YAML tree. The path should include the key name.

Types

type Action

type Action struct {
	Type        ActionType
	Description string
	Path        string
	Success     bool
	Error       error
}

Action represents a single action performed or simulated by the setup service

type ActionType

type ActionType string

ActionType represents the type of action being performed

const (
	ActionWriteFile       ActionType = "write_file"
	ActionAppendFile      ActionType = "append_file"
	ActionCreateDir       ActionType = "create_dir"
	ActionUpdateYAML      ActionType = "update_yaml"
	ActionCreateEcosystem ActionType = "create_ecosystem"
)

type Service

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

Service encapsulates all file I/O and command execution logic for the setup wizard. It respects dry-run mode and maintains a log of actions for the summary screen.

func NewService

func NewService(dryRun bool) *Service

NewService creates a new setup service

func (*Service) Actions

func (s *Service) Actions() []Action

Actions returns all actions performed or simulated

func (*Service) AppendToFile

func (s *Service) AppendToFile(path string, content string) error

AppendToFile appends content to a file, respecting dry-run mode. If the file doesn't exist, it creates it.

func (*Service) FileContains

func (s *Service) FileContains(path string, substr string) (bool, error)

FileContains checks if a file contains the given substring

func (*Service) FileExists

func (s *Service) FileExists(path string) bool

FileExists checks if a file exists at the given path

func (*Service) IsDryRun

func (s *Service) IsDryRun() bool

IsDryRun returns whether the service is in dry-run mode

func (*Service) MkdirAll

func (s *Service) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a directory and all parent directories, respecting dry-run mode

func (*Service) ReadFile

func (s *Service) ReadFile(path string) ([]byte, error)

ReadFile reads a file and returns its content

func (*Service) RunGitInit

func (s *Service) RunGitInit(path string) error

RunGitInit initializes a git repository in the given directory

func (*Service) WriteFile

func (s *Service) WriteFile(path string, content []byte, perm os.FileMode) error

WriteFile writes content to a file, respecting dry-run mode

type TOMLHandler added in v0.6.2

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

TOMLHandler provides utilities for writing TOML configuration files.

func NewTOMLHandler added in v0.6.2

func NewTOMLHandler(service *Service) *TOMLHandler

NewTOMLHandler creates a new TOML handler

func (*TOMLHandler) SaveGlobalConfig added in v0.6.2

func (h *TOMLHandler) SaveGlobalConfig(config map[string]interface{}) error

SaveGlobalConfig saves a configuration map to the global grove configuration file. Uses grove.toml format.

func (*TOMLHandler) SaveTOML added in v0.6.2

func (h *TOMLHandler) SaveTOML(path string, config map[string]interface{}) error

SaveTOML saves a configuration map to a TOML file, respecting dry-run mode.

type YAMLHandler

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

YAMLHandler provides utilities for reading and writing YAML files while preserving comments and structure using yaml.Node.

func NewYAMLHandler

func NewYAMLHandler(service *Service) *YAMLHandler

NewYAMLHandler creates a new YAML handler

func (*YAMLHandler) LoadGlobalConfig

func (h *YAMLHandler) LoadGlobalConfig() (*yaml.Node, error)

LoadGlobalConfig loads the global grove configuration file (~/.config/grove/grove.yml) into a yaml.Node tree. If the file doesn't exist, returns an empty document node.

func (*YAMLHandler) LoadYAML

func (h *YAMLHandler) LoadYAML(path string) (*yaml.Node, error)

LoadYAML loads a YAML file into a yaml.Node tree. If the file doesn't exist, returns an empty document node.

func (*YAMLHandler) SaveGlobalConfig

func (h *YAMLHandler) SaveGlobalConfig(root *yaml.Node) error

SaveGlobalConfig saves a yaml.Node tree back to the global grove configuration file. Respects the service's dry-run mode.

func (*YAMLHandler) SaveYAML

func (h *YAMLHandler) SaveYAML(path string, root *yaml.Node) error

SaveYAML saves a yaml.Node tree to a file, respecting dry-run mode.

Jump to

Keyboard shortcuts

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