appcontext

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppContext

type AppContext struct {
	Console *console.Console // Console provides utilities for writing messages.
	API     *api.API         // API client for interacting with WriftAI's API.
	Docker  *docker.Docker   // Docker client for interacting with WriftAI's Docker registry.

	Project *project.Project // Project contains business logic to handle project related operations.
	Auth    *auth.Auth       // Auth contains business logic to handle auth related operations.

	Version string // Version represents the current version of the built application.
	Commit  string // Commit represents the short commit hash of the version.
	Date    string // Date represents the date when the version was built.
	// contains filtered or unexported fields
}

AppContext holds the core dependencies for the CLI application.

func NewAppContext

func NewAppContext(console *console.Console, api *api.API, docker *docker.Docker,
	project *project.Project, auth *auth.Auth,
	loadConfig func() (*config.Config, error),
	createModel func(*config.Config) (*model.Model, error),
	version, commit, date string) *AppContext

NewAppContext creates and returns a new AppContext struct instance.

func (*AppContext) Config

func (ctx *AppContext) Config() (*config.Config, error)

Config loads and returns the application configuration.

It uses sync.Once to ensure the configuration is loaded only once, caching the result for subsequent calls. If loading fails, the error is also cached and returned on future calls.

func (*AppContext) Model

func (ctx *AppContext) Model() (*model.Model, error)

Model creates and returns a pointer to a model struct instance.

It uses sync.Once to ensure that model struct is only initialized once across multiple calls.

It also calls the AppContext.Config function to load configuration to pass to the model struct during initialization. If config loading fails, or model struct creation fails it returns the corresponding error.

Jump to

Keyboard shortcuts

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