app

package
v0.0.0-...-64da353 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeInvalidInput    = "INVALID_INPUT"
	ErrCodeContainerAccess = "CONTAINER_ACCESS"
	ErrCodeVolumeNotFound  = "VOLUME_NOT_FOUND"
	ErrCodePermission      = "PERMISSION_DENIED"
	ErrCodeTimeout         = "TIMEOUT"
	ErrCodeNotImplemented  = "NOT_IMPLEMENTED"
)

Common error codes

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonError

type CommonError struct {
	Code    string
	Message string
	Cause   error
}

CommonError represents application-level errors

func NewError

func NewError(code, message string, cause error) *CommonError

NewError creates a new CommonError

func (*CommonError) Error

func (e *CommonError) Error() string

func (*CommonError) Unwrap

func (e *CommonError) Unwrap() error

type Context

type Context struct {
	context.Context

	// Output preferences
	OutputFormat string
	Verbose      bool
	Quiet        bool
	NoColor      bool

	// Common timeouts
	DefaultTimeout time.Duration

	// Progress reporting
	ProgressCallback func(message string, percent int)
}

Context holds application-wide configuration and state

func NewContext

func NewContext() *Context

NewContext creates a new application context

func (*Context) Error

func (c *Context) Error(message string)

Error outputs an error message unless quiet

func (*Context) Log

func (c *Context) Log(message string)

Log outputs a message based on verbosity settings

func (*Context) Progress

func (c *Context) Progress(message string, percent int)

Progress reports progress if callback is set

func (*Context) SetProgress

func (c *Context) SetProgress(callback func(string, int))

SetProgress sets the progress callback function

func (*Context) WithCancel

func (c *Context) WithCancel() (*Context, context.CancelFunc)

WithCancel creates a cancellable context

func (*Context) WithTimeout

func (c *Context) WithTimeout(timeout time.Duration) (*Context, context.CancelFunc)

WithTimeout creates a context with timeout

type ProgressUpdate

type ProgressUpdate struct {
	Message     string
	Completed   int64
	Total       int64
	StartedAt   time.Time
	ElapsedTime time.Duration
}

ProgressUpdate represents progress information

func (*ProgressUpdate) ETA

func (p *ProgressUpdate) ETA() time.Duration

ETA estimates time to completion

func (*ProgressUpdate) Percent

func (p *ProgressUpdate) Percent() int

Percent calculates completion percentage

func (*ProgressUpdate) Rate

func (p *ProgressUpdate) Rate() float64

Rate calculates items per second

type VolumeTarget

type VolumeTarget struct {
	VolumeID   uint64
	VolumeName string
	Snapshot   string
}

VolumeTarget represents volume selection across commands

func (*VolumeTarget) IsEmpty

func (vt *VolumeTarget) IsEmpty() bool

IsEmpty returns true if no volume target is specified

func (*VolumeTarget) String

func (vt *VolumeTarget) String() string

String returns a string representation of the volume target

func (*VolumeTarget) Validate

func (vt *VolumeTarget) Validate() error

Validate ensures volume target is valid

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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