savedsel

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 16 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 savedsel keeps export selections by name, in two stores: this account's own (a file each under the state home, private to it) and the manifest's (defaults.export.selections, so they travel with it). Both are read; on a name in both, the account's own wins and the manifest's is listed as shadowed. The export.save_to setting says where a save goes.

Index

Constants

View Source
const (
	StoreUser     = "user"
	StoreManifest = "manifest"
)

The stores.

Variables

View Source
var ErrNotFound = errors.New("no saved selection")

ErrNotFound is a name no store has.

View Source
var Reserved = []string{"selections", "schedule"}

Reserved are names a saved selection cannot take: the built-in lists, and the words `authama export` gives its own meaning.

Stores lists them, the default first.

Functions

func AddSchedule

func AddSchedule(p paths.Paths, s Schedule) error

AddSchedule keeps s, replacing a schedule of the same selection and format (so the folder can be changed by adding it again).

func CheckName

func CheckName(name string) error

CheckName says why name cannot name a saved selection, or nil.

func CheckSchedule

func CheckSchedule(s Schedule) error

CheckSchedule says why s cannot be scheduled, or nil: a selection name, a table format (the SSH client formats write a host list another way), and an absolute folder.

func CheckStore

func CheckStore(store string) error

CheckStore says why store is not a store, or nil.

func DefaultStore

func DefaultStore(get envnames.Getenv) string

DefaultStore is where a save goes when none is named: export.save_to, or the user's own store.

func Delete

func Delete(p paths.Paths, store, name string) error

Delete removes name from store.

func Encode

func Encode(sel selection.Selection) ([]byte, error)

Encode is sel as a store keeps it: indented JSON, its version set.

func RemoveSchedules

func RemoveSchedules(p paths.Paths, selection, format string) (int, error)

RemoveSchedules removes the schedules of selection: in format, or in every format when format is "". It answers how many went.

func Save

func Save(p paths.Paths, store, name string, sel selection.Selection) error

Save keeps sel as name in store. A manifest save goes through the editor, so it is validated and audited like any manifest change; the caller takes the lock and the snapshot a mutation takes.

func SchedulesFile

func SchedulesFile(p paths.Paths) string

SchedulesFile is where this account's export schedules are kept.

Types

type Saved

type Saved struct {
	Name      string              `json:"name"`
	Store     string              `json:"store"`
	Selection selection.Selection `json:"selection"`
	// Shadowed marks a manifest selection hidden by one of this account's
	// own with the same name.
	Shadowed bool `json:"shadowed,omitempty"`
	// Err says why the stored selection cannot be read (another version,
	// say). It is listed, so it can be seen and deleted, never used.
	Err string `json:"error,omitempty"`
}

Saved is one saved selection.

func Get

func Get(p paths.Paths, m *manifest.Manifest, name string) (Saved, error)

Get is the saved selection name: the user's own when there is one, else the manifest's. One that cannot be read is an error saying why.

func List

func List(p paths.Paths, m *manifest.Manifest) ([]Saved, error)

List is every saved selection in both stores, by name, the user's first on a name in both. m may be nil when the manifest cannot be read.

type Schedule

type Schedule struct {
	Selection string `json:"selection"`
	Format    string `json:"format"`
	Folder    string `json:"folder"`
}

Schedule writes a saved selection to a folder each day, in one format, as <selection>.<extension>. Schedules are this account's alone: a folder is a path on this machine, so they never go in the manifest.

func Schedules

func Schedules(p paths.Paths) ([]Schedule, error)

Schedules are this account's export schedules, in the order added.

func (Schedule) File

func (s Schedule) File() (string, error)

File is where s writes.

Jump to

Keyboard shortcuts

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