profile

package
v0.1.433 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package profile stores named snapshots of every agent's settings, and of who gets what from the library, so a whole setup can be switched in one move.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFields added in v0.1.58

func ApplyFields(p map[string]string) (int, error)

ApplyFields writes every value in p that differs from what is set now. It returns the number of changes made and the first error encountered.

func Delete

func Delete(name string) error

Delete removes a profile.

func Fields added in v0.1.58

func Fields() map[string]string

Fields captures the current value of every detected agent's fields.

func Load

func Load() (map[string]Profile, error)

Load reads every profile.

func LongSummary added in v0.1.58

func LongSummary(p Profile) string

LongSummary is Summary, and what the profile gives out from the library.

func Names

func Names(ps map[string]Profile) []string

Names lists profiles alphabetically.

func Path

func Path() string

Path is the profiles file.

func Report added in v0.1.58

func Report(a Applied) []string

Report is what applying a profile did to the library, a line each, for the terminal: none for a profile without the library's setup.

func Save

func Save(name string, p Profile) error

Save stores p under name, replacing any existing profile.

func Summary

func Summary(p Profile) string

Summary renders a profile's models as a short one-line description.

Types

type Applied added in v0.1.58

type Applied struct {
	Changed int // agent fields changed
	// Library is what bringing the library's setup back wrote into the
	// agents; nil for a profile that carries none.
	Library *library.Result
}

Applied is what applying a profile did.

func Apply

func Apply(p Profile) (Applied, error)

Apply writes every field in p that differs from what is set now, then brings the library's setup back when p carries one and writes it into the agents (their files kept aside first). It stops at the first error.

type Profile

type Profile struct {
	// Fields maps "agent.field" to a value.
	Fields map[string]string
	// Library is which agents got which servers and skills, and the
	// instructions; nil for a profile saved while the library was empty,
	// or before profiles kept it, which leaves the library as it is.
	Library *library.Setup
}

Profile is every agent's fields, and the library's setup.

func Snapshot

func Snapshot() (Profile, error)

Snapshot captures every detected agent's fields, and the library's setup unless the library is empty.

func (Profile) MarshalJSON added in v0.1.58

func (p Profile) MarshalJSON() ([]byte, error)

MarshalJSON writes the fields and the library's setup side by side.

func (*Profile) UnmarshalJSON added in v0.1.58

func (p *Profile) UnmarshalJSON(b []byte) error

UnmarshalJSON reads what MarshalJSON writes, and a profile of before, which was the fields alone.

Jump to

Keyboard shortcuts

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