config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config loads, merges, and resolves canvas-cli configuration.

Precedence: explicit flags > environment variables > config file > defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigPath added in v0.2.0

func ConfigPath() string

ConfigPath returns the default config file path using the OS-appropriate config directory:

Linux:   $XDG_CONFIG_HOME/canvas-cli/config.yaml  (default ~/.config)
macOS:   ~/Library/Application Support/canvas-cli/config.yaml
Windows: %APPDATA%\canvas-cli\config.yaml

func LoadConfig

func LoadConfig(configPath, profileOverride string) (*canvas.Config, error)

LoadConfig reads and parses a YAML config file. If configPath is empty it uses ConfigPath(). If profileOverride is non-empty it overrides CurrentProfile. Rejects files with permissions more permissive than 0600 (Unix only; Windows permissions are not checked).

Types

type Options

type Options struct {
	BaseURL string
	Token   string
	Cookie  string
	Profile string
}

Options holds explicit flag values that override everything else.

type ResolvedConfig

type ResolvedConfig struct {
	BaseURL          string
	Token            string
	Cookie           string
	CSRFToken        string
	Profile          string
	Timeout          string
	TimeoutDuration  time.Duration
	Retries          int
	PageSize         int
	Limit            int
	NoPaginate       bool
	ReadOnly         bool
	DefaultCourse    string
	OutputJSONPretty bool
	OutputNoColor    bool
	AuditEnabled     bool
	AuditPath        string
	Warnings         []string
	StartTime        time.Time
}

ResolvedConfig is the final, fully-resolved configuration for a command run.

func Resolve

func Resolve(opts Options, cfg *canvas.Config) (*ResolvedConfig, error)

Resolve merges Options (flags), environment variables, and the parsed config into a ResolvedConfig. It returns an error when required values are missing.

func (*ResolvedConfig) String

func (r *ResolvedConfig) String() string

String returns a human-readable summary with sensitive values redacted.

Jump to

Keyboard shortcuts

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