notify

package
v5.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package notify provides utilities for sending notifications to the user.

This package contains functions for displaying formatted messages to the user, including success, error, warning, info, and activity messages with appropriate symbols and colors, as well as timing information formatting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 and the message type is SuccessType,
	// timing information will be printed in a separate block after the message.
	Timer timer.Timer
	// 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
)

Message type constants. Each type determines the message styling (color and symbol).

Jump to

Keyboard shortcuts

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