config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config provides functionality for managing persistent settings in JSON configuration files. It supports organizing settings into sections, similar to INI files, but using JSON as the storage format. Each section is a top-level key in the JSON object containing key-value pairs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config manages application configuration, automatically storing values in either global or project-specific locations based on the key.

func New

func New(projectPath string) (*Config, error)

New creates a new Config instance. If projectPath is empty, only global config is used. Global config is stored in ~/.config/sandworm/config.json, while project config is stored in .sandworm in the project directory.

func (*Config) Delete

func (c *Config) Delete(key string) error

Delete removes a configuration value

func (*Config) Get

func (c *Config) Get(key string) string

Get retrieves a configuration value. Returns empty string if not found.

func (*Config) GetAllKeys added in v0.2.0

func (c *Config) GetAllKeys() []string

GetAllKeys returns all configuration keys as a slice of strings

func (*Config) Has

func (c *Config) Has(key string) bool

Has checks if a configuration key exists

func (*Config) IsGlobalKey added in v0.2.0

func (c *Config) IsGlobalKey(key string) bool

IsGlobalKey checks if a key is stored in global config

func (*Config) Set

func (c *Config) Set(key, value string) error

Set stores a configuration value and persists it to the appropriate location

Jump to

Keyboard shortcuts

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