config

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlobalConfigFile  = "config.kdl"
	ProjectConfigFile = ".devtool.kdl"
)

KDL configuration file names

Variables

This section is empty.

Functions

func GlobalConfigPath

func GlobalConfigPath() string

GlobalConfigPath returns the path to the global config file.

func WriteDefaultConfig

func WriteDefaultConfig(path string) error

WriteDefaultConfig writes a default config file with documentation.

Types

type CommandConfig

type CommandConfig struct {
	// Command is the executable name.
	Command string `json:"command"`
	// Args are the default arguments.
	Args []string `json:"args"`
	// Description is a human-readable description.
	Description string `json:"description,omitempty"`
	// Timeout is the command timeout in seconds.
	Timeout int `json:"timeout,omitempty"`
	// Persistent indicates this is a long-running process.
	Persistent bool `json:"persistent,omitempty"`
	// Env holds environment variables to set.
	Env map[string]string `json:"env,omitempty"`
}

CommandConfig holds configuration for a single command.

func (*CommandConfig) ToCommandDef

func (c *CommandConfig) ToCommandDef(name string) project.CommandDef

ToCommandDef converts a CommandConfig to a project.CommandDef.

type Config

type Config struct {
	// Version is the config file version.
	Version string `json:"version"`

	// Settings are global server settings.
	Settings Settings `json:"settings"`

	// Languages holds language-specific configurations.
	Languages map[string]LanguageConfig `json:"languages"`
}

Config holds the complete server configuration.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration.

func LoadConfigFile

func LoadConfigFile(path string) (*Config, error)

LoadConfigFile loads configuration from a specific file path.

func LoadGlobalConfig

func LoadGlobalConfig() (*Config, error)

LoadGlobalConfig loads the global configuration from the default location.

func ParseKDLConfig

func ParseKDLConfig(data string) (*Config, error)

ParseKDLConfig parses KDL configuration data.

func (*Config) GetLanguageCommands

func (c *Config) GetLanguageCommands(lang string) []project.CommandDef

GetLanguageCommands returns command definitions for a language.

func (*Config) MergeProjectConfig

func (c *Config) MergeProjectConfig(projConfig *ProjectConfig) *Config

MergeProjectConfig merges per-project config with global config.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the configuration for errors.

type KDLCommand

type KDLCommand struct {
	Command    string            `kdl:"cmd"`
	Args       []string          `kdl:"args"`
	Timeout    int               `kdl:"timeout"`
	Persistent bool              `kdl:"persistent"`
	Env        map[string]string `kdl:"env"`
}

KDLCommand holds a command configuration.

type KDLConfig

type KDLConfig struct {
	Version   string       `kdl:"version"`
	Settings  KDLSettings  `kdl:"settings"`
	Languages KDLLanguages `kdl:"languages"`
}

KDLConfig represents the KDL configuration structure. Uses kdl struct tags for unmarshaling.

type KDLLanguage

type KDLLanguage struct {
	Markers              []string               `kdl:"markers"`
	Priority             int                    `kdl:"priority"`
	PackageManagerDetect bool                   `kdl:"package-manager-detect"`
	Commands             map[string]*KDLCommand `kdl:"commands"`
}

KDLLanguage holds configuration for a specific language.

type KDLLanguages

type KDLLanguages struct {
	Go     *KDLLanguage `kdl:"go"`
	Node   *KDLLanguage `kdl:"node"`
	Python *KDLLanguage `kdl:"python"`
}

KDLLanguages holds language configurations.

type KDLProjectConfig

type KDLProjectConfig struct {
	Language       string                 `kdl:"language"`
	PackageManager string                 `kdl:"package-manager"`
	Commands       map[string]*KDLCommand `kdl:"commands"`
}

KDLProjectConfig holds per-project configuration.

type KDLSettings

type KDLSettings struct {
	DefaultTimeout  int `kdl:"default-timeout"`
	MaxOutputBuffer int `kdl:"max-output-buffer"`
	GracefulTimeout int `kdl:"graceful-timeout"`
}

KDLSettings holds global settings from KDL.

type LanguageConfig

type LanguageConfig struct {
	// Markers are files that identify this project type.
	Markers []string `json:"markers"`
	// Priority determines detection order (higher = first).
	Priority int `json:"priority"`
	// Commands are the available commands for this language.
	Commands map[string]CommandConfig `json:"commands"`
	// PackageManagerDetect enables automatic package manager detection (Node.js).
	PackageManagerDetect bool `json:"package_manager_detect,omitempty"`
}

LanguageConfig holds configuration for a specific language.

type ProjectConfig

type ProjectConfig struct {
	// Language overrides the detected language.
	Language string `json:"language,omitempty"`
	// PackageManager overrides the detected package manager.
	PackageManager string `json:"package_manager,omitempty"`
	// Commands override default commands.
	Commands map[string]CommandConfig `json:"commands,omitempty"`
}

ProjectConfig holds per-project configuration from .devtool.kdl.

func LoadProjectConfig

func LoadProjectConfig(projectPath string) (*ProjectConfig, error)

LoadProjectConfig loads per-project configuration from .devtool.kdl.

func ParseProjectConfig

func ParseProjectConfig(data string) (*ProjectConfig, error)

ParseProjectConfig parses per-project KDL configuration.

type Settings

type Settings struct {
	// DefaultTimeout is the default process timeout.
	DefaultTimeout time.Duration `json:"default_timeout"`
	// MaxOutputBuffer is the per-stream output buffer size.
	MaxOutputBuffer int `json:"max_output_buffer"`
	// GracefulTimeout is the graceful shutdown timeout.
	GracefulTimeout time.Duration `json:"graceful_timeout"`
}

Settings holds global configuration settings.

Jump to

Keyboard shortcuts

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