cliconfig

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTelemetryExplicitlySet added in v0.5.0

func IsTelemetryExplicitlySet() bool

IsTelemetryExplicitlySet returns true if telemetry.enabled is explicitly set in config or environment.

func UpdateTelemetrySettings added in v0.5.0

func UpdateTelemetrySettings(enabled bool) error

UpdateTelemetrySettings updates the telemetry configuration in the config file. Uses yaml.Node to preserve comments and formatting.

func UpdateTelemetrySettingsWithOptions added in v0.5.0

func UpdateTelemetrySettingsWithOptions(enabled bool, opts UpdateOptions) error

UpdateTelemetrySettingsWithOptions is the testable version of UpdateTelemetrySettings

Types

type Config

type Config struct {
	// OneKeyMap is the path to the main onekeymap configuration file.
	OneKeyMap string `mapstructure:"onekeymap"`
	// Telemetry holds OpenTelemetry configuration.
	Telemetry TelemetryConfig `mapstructure:"telemetry"`
	// ServerListen is the server listen address (e.g., "tcp://127.0.0.1:50051" or "unix:///tmp/onekeymap.sock").
	ServerListen string `mapstructure:"server.listen"`
	// Editors holds configuration for different editors.
	Editors map[string]EditorConfig `mapstructure:"editors"`
}

func NewConfig

func NewConfig(sandbox bool) (*Config, error)

NewConfig initializes and returns a new Config object. It sets defaults, binds environment variables, reads config files, and unmarshals the result.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid.

type EditorConfig

type EditorConfig struct {
	// KeymapPath is the path to the editor's keymap file.
	KeymapPath string `mapstructure:"keymap_path"`
	// TODO(xinnjie): Sync command is not implement yet
	// SyncEnabled specifies whether keymap syncing is enabled for this editor.
	SyncEnabled bool `mapstructure:"sync_enabled"`
}

EditorConfig holds per-editor configuration settings.

type TelemetryConfig added in v0.5.0

type TelemetryConfig struct {
	// Enabled controls whether telemetry is enabled (default: false).
	// When this field is explicitly set in config (true or false), no prompt will be shown.
	// When not set, a prompt will be displayed to ask user's preference.
	Enabled bool `mapstructure:"enabled"`
	// Endpoint is the OTLP exporter endpoint (host:port, without http:// or https://).
	// Example: "otlp-gateway-prod-us-central-0.grafana.net:443"
	Endpoint string `mapstructure:"endpoint"`
	// Headers are custom headers for OTLP exporter (e.g., for authentication).
	// Format: "key1=value1,key2=value2"
	Headers string `mapstructure:"headers"`
}

TelemetryConfig holds OpenTelemetry configuration.

type UpdateOptions added in v0.5.0

type UpdateOptions struct {
	GetConfigFile func() string
	GetHomeDir    func() (string, error)
	MkdirAll      func(path string, perm os.FileMode) error
	GetTemplate   func() ([]byte, error)
}

UpdateOptions contains dependencies for UpdateTelemetrySettings to enable testing

Jump to

Keyboard shortcuts

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