outfmt

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorReset  = "\033[0m"
	ColorRed    = "\033[31m"
	ColorGreen  = "\033[32m"
	ColorYellow = "\033[33m"
	ColorBlue   = "\033[34m"
	ColorPurple = "\033[35m"
	ColorCyan   = "\033[36m"
	ColorWhite  = "\033[37m"
	ColorGray   = "\033[90m"

	// 粗体颜色
	ColorBoldRed    = "\033[1;31m"
	ColorBoldGreen  = "\033[1;32m"
	ColorBoldYellow = "\033[1;33m"
	ColorBoldBlue   = "\033[1;34m"
	ColorBoldPurple = "\033[1;35m"
	ColorBoldCyan   = "\033[1;36m"
	ColorBoldWhite  = "\033[1;37m"
)

Color 定义颜色常量

View Source
const DefaultFillWidth = 80

DefaultFillWidth is the default maximum line width for FillParagraph.

Variables

This section is empty.

Functions

func Colorize

func Colorize(color, text string) string

Colorize 根据是否启用颜色返回带颜色的字符串

func Debug

func Debug(format string, a ...any)

Debug 输出调试信息(仅在verbose模式下显示)

func DebugBytes

func DebugBytes(lang string, b []byte)

DebugBytes output bytes if debug

func Error

func Error(format string, a ...any)

Error 输出错误信息(始终显示)

func Fatal

func Fatal(format string, a ...any)

Fatal 输出致命错误信息并退出(始终显示)

func FillParagraph added in v0.7.5

func FillParagraph(text string, maxWidth int) string

FillParagraph wraps text at word boundaries to fit within maxWidth characters. It preserves double-newline paragraph breaks and normalizes single newlines to spaces within a paragraph. This is designed for English text; Chinese support will be added later.

If maxWidth <= 0, DefaultFillWidth is used.

func GetColorEnabled

func GetColorEnabled() bool

GetColorEnabled returns output color enabled

func GetOutputMode

func GetOutputMode() string

func GetShowTimestamp

func GetShowTimestamp() bool

func GetVerbose

func GetVerbose() bool

func Info

func Info(format string, a ...any)

Info 输出普通信息(始终显示)

func IsVerbose

func IsVerbose() bool

IsVerbose 检查是否启用详细输出

func JSONMarshal

func JSONMarshal(v any) ([]byte, error)

func NewTabwrt

func NewTabwrt() *tabwrt

func Notice

func Notice(format string, a ...any)

Notice 输出注意信息

func OrgToMarkdown added in v0.7.9

func OrgToMarkdown(input string) string

OrgToMarkdown converts Org mode content to Markdown. This is the reverse of MarkdownToOrgConverter, used when output mode is "org" and user input (org format) needs to be stored internally as Markdown.

func Print

func Print(a ...any) (n int, err error)

Print 输出一行文本(保持向后兼容)

func PrintBullet

func PrintBullet(text string)

PrintBullet 输出项目符号

func PrintClimeinContent added in v0.7.8

func PrintClimeinContent(ctx context.Context, content string)

func PrintContent

func PrintContent(ctx context.Context, reasoning, content string)

func PrintHeader

func PrintHeader(title string)

PrintHeader 输出标题

func PrintJSON

func PrintJSON(data any) error

PrintJSON 输出JSON格式数据

func PrintKeyValue

func PrintKeyValue(key, value string)

PrintKeyValue 输出键值对

func PrintSection

func PrintSection(title string)

PrintSection 输出章节标题

func PrintSubSection

func PrintSubSection(title string)

PrintSubSection 输出子章节标题

func PrintUserContent added in v0.7.8

func PrintUserContent(ctx context.Context, content string)

func Printf

func Printf(format string, a ...any) (n int, err error)

Printf 输出格式化文本(保持向后兼容)

func Println

func Println(a ...any) (n int, err error)

Println 输出一行文本(保持向后兼容)

func SetColorEnabled

func SetColorEnabled(enabled bool)

SetColorEnabled 设置是否启用颜色输出

func SetErrorWriter

func SetErrorWriter(w io.Writer)

SetErrorWriter 设置错误输出写入器

func SetOutputMode

func SetOutputMode(mode string)

SetOutputMode 设置输出模式

func SetOutputWriter

func SetOutputWriter(w io.Writer)

SetOutputWriter 设置输出写入器

func SetShowTimestamp

func SetShowTimestamp(show bool)

SetShowTimestamp 设置是否显示时间戳

func SetVerbose

func SetVerbose(verbose bool)

SetVerbose 设置是否显示详细输出

func StartWaiting

func StartWaiting(duration time.Duration) func()

func Success

func Success(format string, a ...any)

Success 输出成功信息

func Warn

func Warn(format string, a ...any)

Warn 输出警告信息(始终显示)

Types

type LogLevel

type LogLevel int

LogLevel 定义日志级别(保留类型但不再使用多级过滤)

const (
	// LogLevelDebug 调试级别
	LogLevelDebug LogLevel = iota
	// LogLevelInfo 信息级别
	LogLevelInfo
	// LogLevelWarn 警告级别
	LogLevelWarn
	// LogLevelError 错误级别
	LogLevelError
	// LogLevelFatal 致命级别
	LogLevelFatal
)

func (LogLevel) String

func (logLevel LogLevel) String() string

type MarkdownToOrgConverter

type MarkdownToOrgConverter struct {
	// contains filtered or unexported fields
}

MarkdownToOrgConverter converts Markdown to Org mode

func NewMarkdownToOrgConverter

func NewMarkdownToOrgConverter() *MarkdownToOrgConverter

NewMarkdownToOrgConverter creates a new converter

func (*MarkdownToOrgConverter) ConvertLine

func (c *MarkdownToOrgConverter) ConvertLine(line string) string

ConvertLine converts a single line of Markdown to Org mode

func (*MarkdownToOrgConverter) ConvertLines

func (c *MarkdownToOrgConverter) ConvertLines(input string, output io.Writer) error

type ProgressBar

type ProgressBar struct {
	// contains filtered or unexported fields
}

ProgressBar 进度条结构

func NewProgressBar

func NewProgressBar(total int64) *ProgressBar

NewProgressBar 创建新的进度条

func (*ProgressBar) Finish

func (pb *ProgressBar) Finish()

Finish 完成进度条

func (*ProgressBar) Increment

func (pb *ProgressBar) Increment(delta int64)

Increment 增加进度

func (*ProgressBar) SetShowValue

func (pb *ProgressBar) SetShowValue(show bool)

SetShowValue 设置是否显示数值

func (*ProgressBar) SetWidth

func (pb *ProgressBar) SetWidth(width int)

SetWidth 设置进度条宽度

func (*ProgressBar) Update

func (pb *ProgressBar) Update(current int64)

Update 更新进度

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner 加载动画结构

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner 创建新的加载动画

func (*Spinner) Start

func (s *Spinner) Start()

Start 开始加载动画

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop 停止加载动画

func (*Spinner) StopWithMessage

func (s *Spinner) StopWithMessage(message string, success bool)

StopWithMessage 停止加载动画并显示消息

type WaitingManager

type WaitingManager struct {
	// contains filtered or unexported fields
}

WaitingManager 等待动画管理器

func GetWaitingManager

func GetWaitingManager() *WaitingManager

GetWaitingManager 获取等待动画管理器单例

func (*WaitingManager) IsActive

func (w *WaitingManager) IsActive() bool

IsActive 检查等待动画是否活跃

func (*WaitingManager) RecordOutput

func (w *WaitingManager) RecordOutput()

RecordOutput 记录输出事件,重置等待计时器

func (*WaitingManager) StartWaiting

func (w *WaitingManager) StartWaiting(delay time.Duration)

StartWaiting 开始等待监控 如果 delay 秒内没有输出,则启动等待动画

func (*WaitingManager) StopWaiting

func (w *WaitingManager) StopWaiting()

StopWaiting 停止等待动画

Source Files

  • emacs_waiting.go
  • fill.go
  • markdown2org.go
  • org2markdown.go
  • output.go
  • table.go
  • tabwrt.go
  • waiting_animation.go

Jump to

Keyboard shortcuts

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