config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config persists mmcli connection contexts in a JSON file under the user's XDG config dir. Secrets (password, cached token) are NOT stored here — they live in the keyring (see internal/secrets).

Index

Constants

View Source
const AuthToken = "token"

AuthToken marks a context authenticated by a personal access token.

Variables

View Source
var ErrNoContext = errors.New("no context configured; run `mmcli login` first")

ErrNoContext means no context is selected / configured yet.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the config file location, honoring XDG_CONFIG_HOME.

Types

type Config

type Config struct {
	CurrentName string             `json:"current"`
	Contexts    map[string]Context `json:"contexts"`
	// contains filtered or unexported fields
}

Config is the on-disk document. The file path is kept separately and is not serialized.

func Load

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

Load reads the config at path. A missing file yields an empty, ready-to-use Config rather than an error.

func (*Config) Current

func (c *Config) Current() (string, Context, error)

Current returns the active context and its name.

func (*Config) Delete

func (c *Config) Delete(name string)

Delete removes a context; clears Current if it pointed there.

func (*Config) Get

func (c *Config) Get(name string) (Context, bool)

Get returns a named context.

func (*Config) Save

func (c *Config) Save() error

Save writes the config back to disk with 0600 permissions.

func (*Config) Set

func (c *Config) Set(name string, ctx Context)

Set stores/replaces a context and makes it current.

func (*Config) Use

func (c *Config) Use(name string) error

Use switches the active context.

type Context

type Context struct {
	URL         string `json:"url"`
	LoginID     string `json:"login_id"`
	DefaultTeam string `json:"default_team,omitempty"`
	// Auth is AuthToken for personal access token contexts (bot accounts
	// cannot log in with a password); empty means login_id/password.
	Auth string `json:"auth,omitempty"`
}

Context holds non-secret connection parameters for one Mattermost server.

Jump to

Keyboard shortcuts

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