notify

package
v1.13.1 Latest Latest
Warning

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

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

Documentation

Overview

Package notify provides utilities for sending notifications to the user.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTiming

func FormatTiming(total, stage time.Duration, isMultiStage bool) string

FormatTiming formats timing durations into a display string using Go's Duration.String() method. Returns "[stage: X|total: Y]" for multi-stage commands when isMultiStage is true. Returns "[stage: X]" for single-stage commands. Uses Go's standard Duration.String() which provides appropriate precision automatically.

func WriteMessage

func WriteMessage(msg Message)

WriteMessage writes a formatted message based on the message configuration. It handles message styling, optional timing information, and proper output formatting.

Types

type Message

type Message struct {
	// Type determines the message styling (color, symbol).
	Type MessageType
	// Content is the main message text to display.
	Content string
	// Timer is optional. If provided, timing information will be appended to the message.
	Timer timer.Timer
	// MultiStage MUST be set to true for multi-stage timers (i.e., when the command advances through stages).
	// If false, the timing output will be rendered in single-stage form regardless of internal durations.
	MultiStage bool
	// Emoji is used only for TitleType messages to customize the title icon.
	Emoji string
	// Writer is the output destination. If nil, defaults to os.Stdout.
	Writer io.Writer
	// Args are format arguments for Content if it contains format specifiers.
	Args []any
}

Message represents a notification message to be displayed to the user.

type MessageType

type MessageType int

MessageType defines the type of notification message.

const (
	// ErrorType represents an error message (red, with ✗ symbol).
	ErrorType MessageType = iota
	// WarningType represents a warning message (yellow, with ⚠ symbol).
	WarningType
	// ActivityType represents an activity/progress message (default color, with ► symbol).
	ActivityType
	// GenerateType represents a file generation message (default color, with ✚ symbol).
	GenerateType
	// SuccessType represents a success message (green, with ✔ symbol).
	SuccessType
	// InfoType represents an informational message (blue, with ℹ symbol).
	InfoType
	// TitleType represents a title/header message (bold, with emoji (custom or default)).
	TitleType
)

Jump to

Keyboard shortcuts

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