Documentation
¶
Index ¶
- Constants
- Variables
- func ColorProfile() termenv.Profile
- func FromCmdContext(ctx context.Context) (*cmdContext, bool)
- func HasDarkBackground() bool
- func KeyEnabled(enabled bool) key.BindingOpt
- func NewOutput(w io.Writer, opts ...termenv.OutputOption) *termenv.Output
- func NewWithDB(w io.Writer, db *dagui.DB) *frontendPretty
- func WithPrintTraceLink(ctx context.Context, printTraceLink bool) context.Context
- type AdaptiveColor
- type Dump
- type Frontend
- type FrontendMetricExporter
- func (fe FrontendMetricExporter) Aggregation(ik sdkmetric.InstrumentKind) sdkmetric.Aggregation
- func (fe FrontendMetricExporter) Background(cmd tea.ExecCommand, raw bool) error
- func (fe FrontendMetricExporter) Close() error
- func (fe FrontendMetricExporter) ConnectedToEngine(ctx context.Context, name string, version string, clientID string)
- func (fe FrontendMetricExporter) Export(ctx context.Context, resourceMetrics *metricdata.ResourceMetrics) error
- func (fe FrontendMetricExporter) FinalRender(w io.Writer) error
- func (fe FrontendMetricExporter) ForceFlush(context.Context) error
- func (fe FrontendMetricExporter) HandlePrompt(ctx context.Context, prompt string, dest any) error
- func (fe FrontendMetricExporter) Init() tea.Cmd
- func (fe FrontendMetricExporter) LogExporter() sdklog.Exporter
- func (fe FrontendMetricExporter) MetricExporter() sdkmetric.Exporter
- func (fe FrontendMetricExporter) Opts() *dagui.FrontendOpts
- func (fe FrontendMetricExporter) Render(out TermOutput) error
- func (fe FrontendMetricExporter) RevealAllSpans()
- func (fe FrontendMetricExporter) Run(ctx context.Context, opts dagui.FrontendOpts, run func(context.Context) error) error
- func (fe FrontendMetricExporter) SetCloudURL(ctx context.Context, url string, msg string, logged bool)
- func (fe FrontendMetricExporter) SetCustomExit(fn func())
- func (fe FrontendMetricExporter) SetPrimary(spanID dagui.SpanID)
- func (fe FrontendMetricExporter) SetVerbosity(n int)
- func (fe FrontendMetricExporter) Shell(ctx context.Context, handler ShellHandler)
- func (fe FrontendMetricExporter) Shutdown(ctx context.Context) error
- func (fe FrontendMetricExporter) SpanExporter() sdktrace.SpanExporter
- func (fe FrontendMetricExporter) Temporality(ik sdkmetric.InstrumentKind) metricdata.Temporality
- func (fe FrontendMetricExporter) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (fe FrontendMetricExporter) View() string
- type Markdown
- type PlainFrontendMetricExporter
- func (fe PlainFrontendMetricExporter) Aggregation(ik sdkmetric.InstrumentKind) sdkmetric.Aggregation
- func (fe PlainFrontendMetricExporter) Background(cmd tea.ExecCommand, raw bool) error
- func (fe PlainFrontendMetricExporter) ConnectedToEngine(ctx context.Context, name string, version string, clientID string)
- func (fe PlainFrontendMetricExporter) Export(ctx context.Context, resourceMetrics *metricdata.ResourceMetrics) error
- func (fe PlainFrontendMetricExporter) ForceFlush(context.Context) error
- func (fe PlainFrontendMetricExporter) HandlePrompt(ctx context.Context, prompt string, dest any) error
- func (fe PlainFrontendMetricExporter) LogExporter() sdklog.Exporter
- func (fe PlainFrontendMetricExporter) MetricExporter() sdkmetric.Exporter
- func (fe PlainFrontendMetricExporter) Opts() *dagui.FrontendOpts
- func (fe PlainFrontendMetricExporter) RevealAllSpans()
- func (fe PlainFrontendMetricExporter) Run(ctx context.Context, opts dagui.FrontendOpts, run func(context.Context) error) error
- func (fe PlainFrontendMetricExporter) SetCloudURL(ctx context.Context, url string, msg string, logged bool)
- func (fe PlainFrontendMetricExporter) SetCustomExit(fn func())
- func (fe PlainFrontendMetricExporter) SetPrimary(spanID dagui.SpanID)
- func (fe PlainFrontendMetricExporter) SetVerbosity(n int)
- func (fe PlainFrontendMetricExporter) Shell(ctx context.Context, handler ShellHandler)
- func (fe PlainFrontendMetricExporter) Shutdown(ctx context.Context) error
- func (fe PlainFrontendMetricExporter) SpanExporter() sdktrace.SpanExporter
- func (fe PlainFrontendMetricExporter) Temporality(ik sdkmetric.InstrumentKind) metricdata.Temporality
- type ShellHandler
- type TermOutput
- type UpdatePromptMsg
- type Vterm
- func (term *Vterm) Init() tea.Cmd
- func (term *Vterm) LastLine() string
- func (term *Vterm) Print(w io.Writer) error
- func (term *Vterm) Render(w io.Writer, offset, height int)
- func (term *Vterm) ScrollPercent() float64
- func (term *Vterm) SetHeight(height int)
- func (term *Vterm) SetPrefix(prefix string)
- func (term *Vterm) SetWidth(width int)
- func (term *Vterm) Term() *midterm.Terminal
- func (term *Vterm) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (term *Vterm) UsedHeight() int
- func (term *Vterm) View() string
- func (term *Vterm) Write(p []byte) (int, error)
- func (term *Vterm) WriteMarkdown(p []byte) (int, error)
Constants ¶
const ( Block = "█" Block75 = "▓" Block50 = "▒" Block25 = "░" CaretDownEmpty = "▽" CaretDownFilled = "▼" CaretLeftFilled = "◀" // "<" CaretRightEmpty = "▷" // ">" CaretRightFilled = "▶" // ">" CornerBottomLeft = "╰" CornerBottomRight = "╯" CornerTopLeft = "╭" CornerTopRight = "╮" CrossBar = "┼" DotEmpty = "○" DotFilled = "●" HorizBar = "─" HorizBottomBar = "┬" HorizHalfLeftBar = "╴" HorizHalfRightBar = "╶" HorizTopBar = "┴" HorizTopBoldBar = "┻" InactiveGroupSymbol = VertBar TaskSymbol = VertRightBoldBar VertBar = "│" VertBoldBar = "┃" VertDottedBar = "┊" // ┊┆┇┋╎ VertLeftBar = "┤" VertLeftBoldBar = "┫" VertRightBar = "├" VertRightBoldBar = "┣" IconSkipped = "∅" IconSuccess = "✔" IconFailure = "✘" IconCached = "$" // cache money Diamond = "◆" LLMPrompt = "❯" // We need a prompt that conveys the unique nature of the Dagger shell. Per gpt4: // The ⋈ symbol, known as the bowtie, has deep roots in relational databases and set theory, // where it denotes a join operation. This makes it especially fitting for a DAG environment, // as it suggests the idea of dependencies, intersections, and points where separate paths // or data sets come together. ShellPrompt = "⋈" )
Variables ¶
var ( ANSIBlack = lipgloss.Color("0") ANSIRed = lipgloss.Color("1") ANSIGreen = lipgloss.Color("2") ANSIYellow = lipgloss.Color("3") ANSIBlue = lipgloss.Color("4") ANSIMagenta = lipgloss.Color("5") ANSICyan = lipgloss.Color("6") ANSIWhite = lipgloss.Color("7") ANSIBrightBlack = lipgloss.Color("8") ANSIBrightRed = lipgloss.Color("9") ANSIBrightGreen = lipgloss.Color("10") ANSIBrightYellow = lipgloss.Color("11") ANSIBrightBlue = lipgloss.Color("12") ANSIBrightMagenta = lipgloss.Color("13") ANSIBrightCyan = lipgloss.Color("14") ANSIBrightWhite = lipgloss.Color("15") )
var ErrInterrupted = errors.New("interrupted")
var ErrShellExited = errors.New("shell exited")
var KeymapStyle = lipgloss.NewStyle(). Foreground(lipgloss.ANSIColor(termenv.ANSIBrightBlack))
var MarkdownStyle = styles.LightStyleConfig
var SkipLoggedOutTraceMsgEnvs = []string{
"DAGGER_NO_NAG",
"NOTHANKS", "SHUTUP", "GOAWAY", "STOPIT",
}
Functions ¶
func ColorProfile ¶ added in v0.11.1
ColorProfile returns Ascii if, and only if, NO_COLOR or similar is set. Otherwise it returns termenv.ANSI, allowing colors to be used.
Note that color profiles beyond simple ANSI are not used by Progrock. 16 colors is all you need. Anything else disrespects the user's color scheme preferences.
func FromCmdContext ¶ added in v0.13.0
func HasDarkBackground ¶ added in v0.17.0
func HasDarkBackground() bool
func KeyEnabled ¶ added in v0.17.0
func KeyEnabled(enabled bool) key.BindingOpt
func NewOutput ¶ added in v0.11.1
NewOutput returns a termenv.Output that will always use color, regardless of whether w is a TTY, unless NO_COLOR is explicitly set.
Progrock is opinionated here. Termenv disables colors by default if stdout is not a TTY or if the CI env var is set. We don't want that, because folks deserve colorful output in CI too.
To disable colors, set NO_COLOR (https://no-color.org/).
Types ¶
type AdaptiveColor ¶ added in v0.17.0
func (AdaptiveColor) Sequence ¶ added in v0.17.0
func (c AdaptiveColor) Sequence(bg bool) string
type Frontend ¶
type Frontend interface {
// Run starts a frontend, and runs the target function.
Run(ctx context.Context, opts dagui.FrontendOpts, f func(context.Context) error) error
// Opts returns the opts of the currently running frontend.
Opts() *dagui.FrontendOpts
SetCustomExit(fn func())
SetVerbosity(n int)
// SetPrimary tells the frontend which span should be treated like the focal
// point of the command. Its output will be displayed at the end, and its
// children will be promoted to the "top-level" of the TUI.
SetPrimary(spanID dagui.SpanID)
Background(cmd tea.ExecCommand, raw bool) error
// RevealAllSpans tells the frontend to show all spans, not just
// the spans beneath the primary span.
RevealAllSpans()
// Can consume otel spans, logs and metrics.
SpanExporter() sdktrace.SpanExporter
LogExporter() sdklog.Exporter
MetricExporter() sdkmetric.Exporter
// ConnectedToEngine is called when the CLI connects to an engine.
ConnectedToEngine(ctx context.Context, name string, version string, clientID string)
// SetCloudURL is called after the CLI checks auth and sets the cloud URL.
SetCloudURL(ctx context.Context, url string, msg string, logged bool)
// Shell is called when the CLI enters interactive mode.
Shell(ctx context.Context, handler ShellHandler)
session.PromptHandler
}
func NewReporter ¶ added in v0.15.0
type FrontendMetricExporter ¶ added in v0.13.6
type FrontendMetricExporter struct {
// contains filtered or unexported fields
}
func (FrontendMetricExporter) Aggregation ¶ added in v0.13.6
func (fe FrontendMetricExporter) Aggregation(ik sdkmetric.InstrumentKind) sdkmetric.Aggregation
func (FrontendMetricExporter) Background ¶ added in v0.13.6
func (fe FrontendMetricExporter) Background(cmd tea.ExecCommand, raw bool) error
func (FrontendMetricExporter) Close ¶ added in v0.13.6
func (fe FrontendMetricExporter) Close() error
func (FrontendMetricExporter) ConnectedToEngine ¶ added in v0.13.6
func (FrontendMetricExporter) Export ¶ added in v0.13.6
func (fe FrontendMetricExporter) Export(ctx context.Context, resourceMetrics *metricdata.ResourceMetrics) error
func (FrontendMetricExporter) FinalRender ¶ added in v0.15.0
FinalRender is called after the program has finished running and prints the final output after the TUI has exited.
func (FrontendMetricExporter) ForceFlush ¶ added in v0.13.6
func (fe FrontendMetricExporter) ForceFlush(context.Context) error
func (FrontendMetricExporter) HandlePrompt ¶ added in v0.17.0
func (FrontendMetricExporter) LogExporter ¶ added in v0.13.6
func (FrontendMetricExporter) MetricExporter ¶ added in v0.13.6
func (FrontendMetricExporter) Opts ¶ added in v0.13.6
func (fe FrontendMetricExporter) Opts() *dagui.FrontendOpts
func (FrontendMetricExporter) Render ¶ added in v0.13.6
func (fe FrontendMetricExporter) Render(out TermOutput) error
func (FrontendMetricExporter) RevealAllSpans ¶ added in v0.15.0
func (fe FrontendMetricExporter) RevealAllSpans()
func (FrontendMetricExporter) Run ¶ added in v0.13.6
func (fe FrontendMetricExporter) Run(ctx context.Context, opts dagui.FrontendOpts, run func(context.Context) error) error
Run starts the TUI, calls the run function, stops the TUI, and finally prints the primary output to the appropriate stdout/stderr streams.
func (FrontendMetricExporter) SetCloudURL ¶ added in v0.13.6
func (FrontendMetricExporter) SetCustomExit ¶ added in v0.15.3
func (fe FrontendMetricExporter) SetCustomExit(fn func())
func (FrontendMetricExporter) SetPrimary ¶ added in v0.13.6
func (FrontendMetricExporter) SetVerbosity ¶ added in v0.15.3
func (fe FrontendMetricExporter) SetVerbosity(n int)
func (FrontendMetricExporter) Shell ¶ added in v0.16.3
func (fe FrontendMetricExporter) Shell(ctx context.Context, handler ShellHandler)
func (FrontendMetricExporter) SpanExporter ¶ added in v0.13.6
func (fe FrontendMetricExporter) SpanExporter() sdktrace.SpanExporter
func (FrontendMetricExporter) Temporality ¶ added in v0.13.6
func (fe FrontendMetricExporter) Temporality(ik sdkmetric.InstrumentKind) metricdata.Temporality
type Markdown ¶ added in v0.17.0
type PlainFrontendMetricExporter ¶ added in v0.13.6
type PlainFrontendMetricExporter struct {
// contains filtered or unexported fields
}
func (PlainFrontendMetricExporter) Aggregation ¶ added in v0.13.6
func (fe PlainFrontendMetricExporter) Aggregation(ik sdkmetric.InstrumentKind) sdkmetric.Aggregation
func (PlainFrontendMetricExporter) Background ¶ added in v0.13.6
func (fe PlainFrontendMetricExporter) Background(cmd tea.ExecCommand, raw bool) error
func (PlainFrontendMetricExporter) ConnectedToEngine ¶ added in v0.13.6
func (PlainFrontendMetricExporter) Export ¶ added in v0.13.6
func (fe PlainFrontendMetricExporter) Export(ctx context.Context, resourceMetrics *metricdata.ResourceMetrics) error
func (PlainFrontendMetricExporter) ForceFlush ¶ added in v0.13.6
func (fe PlainFrontendMetricExporter) ForceFlush(context.Context) error
func (PlainFrontendMetricExporter) HandlePrompt ¶ added in v0.17.0
func (PlainFrontendMetricExporter) LogExporter ¶ added in v0.13.6
func (PlainFrontendMetricExporter) MetricExporter ¶ added in v0.13.6
func (PlainFrontendMetricExporter) Opts ¶ added in v0.13.6
func (fe PlainFrontendMetricExporter) Opts() *dagui.FrontendOpts
func (PlainFrontendMetricExporter) RevealAllSpans ¶ added in v0.15.0
func (fe PlainFrontendMetricExporter) RevealAllSpans()
func (PlainFrontendMetricExporter) SetCloudURL ¶ added in v0.13.6
func (PlainFrontendMetricExporter) SetCustomExit ¶ added in v0.15.3
func (fe PlainFrontendMetricExporter) SetCustomExit(fn func())
func (PlainFrontendMetricExporter) SetPrimary ¶ added in v0.13.6
func (PlainFrontendMetricExporter) SetVerbosity ¶ added in v0.15.3
func (fe PlainFrontendMetricExporter) SetVerbosity(n int)
func (PlainFrontendMetricExporter) Shell ¶ added in v0.16.3
func (fe PlainFrontendMetricExporter) Shell(ctx context.Context, handler ShellHandler)
func (PlainFrontendMetricExporter) SpanExporter ¶ added in v0.13.6
func (fe PlainFrontendMetricExporter) SpanExporter() sdktrace.SpanExporter
func (PlainFrontendMetricExporter) Temporality ¶ added in v0.13.6
func (fe PlainFrontendMetricExporter) Temporality(ik sdkmetric.InstrumentKind) metricdata.Temporality
type ShellHandler ¶ added in v0.17.0
type ShellHandler interface {
// Handle processes shell input
Handle(ctx context.Context, input string) error
// AutoComplete provides shell auto-completion functionality
AutoComplete(entireInput [][]rune, line, col int) (string, editline.Completions)
// IsComplete determines if the current input is a complete command
IsComplete(entireInput [][]rune, line int, col int) bool
// Prompt generates the shell prompt string
Prompt(ctx context.Context, out TermOutput, fg termenv.Color) (string, tea.Cmd)
// Keys returns the keys that will be displayed when the input is focused
KeyBindings() []key.Binding
// ReactToInput allows reacting to live input before it's submitted
ReactToInput(ctx context.Context, msg tea.KeyMsg) tea.Cmd
// Shell handlers can man-in-the-middle history items to preserve per-entry modes etc.
editline.HistoryEncoder
}
ShellHandler defines the interface for handling shell interactions
type TermOutput ¶ added in v0.16.3
TermOutput is an interface that captures the methods we need from termenv.Output
type UpdatePromptMsg ¶ added in v0.17.0
type UpdatePromptMsg struct{}
type Vterm ¶ added in v0.9.9
type Vterm struct {
Offset int
Height int
Width int
Prefix string
Profile termenv.Profile
// contains filtered or unexported fields
}
func (*Vterm) LastLine ¶ added in v0.9.9
LastLine returns the last line of visible text, with ANSI formatting, but without any trailing whitespace.
func (*Vterm) Render ¶ added in v0.9.9
Bytes returns the output for the given region of the terminal, with ANSI formatting.