state

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package state is in charge of storing and reading application state.

Index

Constants

View Source
const (
	// ViewHostList mode is active when we browse through a list of hostnames.
	ViewHostList view = iota
	// ViewGroupList mode is active when the app displays available host groups.
	ViewGroupList
	// ViewEditItem mode is active when we edit existing or add a new host.
	ViewEditItem
	// ViewMessage mode is active when there was an error when attempted to connect to a remote host.
	ViewMessage
)

Variables

This section is empty.

Functions

func IsInitialized added in v1.4.0

func IsInitialized() bool

IsInitialized - checks if the application state is initialized.

Types

type Application added in v1.4.0

type Application struct {
	Selected int `yaml:"selected"`

	Logger       iLogger               `yaml:"-"`
	CurrentView  view                  `yaml:"-"`
	Width        int                   `yaml:"-"`
	Height       int                   `yaml:"-"`
	ScreenLayout constant.ScreenLayout `yaml:"screenLayout,omitempty"`
	Group        string                `yaml:"group,omitempty"`
	// SSHConfigEnabled is a part of ApplicationState, not user config, because it is a feature flag
	// which is persisted across application restarts. In other words, once defined, it will be
	// persisted in the state.yaml file and will be used in the next application run.
	SSHConfigEnabled  bool                      `yaml:"enable_ssh_config"`
	ApplicationConfig application.Configuration `yaml:"-"`
	Context           context.Context           `yaml:"-"`
	// contains filtered or unexported fields
}

Application stores application state.

func Create added in v1.4.0

func Create(appContext context.Context,
	appConfig application.Configuration,
	lg iLogger,
) *Application

Create - creates application state.

func Get

func Get() *Application

Get - returns application state.

func (*Application) Persist added in v1.4.0

func (as *Application) Persist() error

Persist saves app state to disk.

func (*Application) PrintConfig added in v1.4.0

func (as *Application) PrintConfig()

PrintConfig outputs user-definable parameters in the console.

type Once added in v1.4.0

type Once interface {
	Do(func())
}

Once - this interface is used to avoid sync.Once restrictions in unit-tests.

Jump to

Keyboard shortcuts

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