Documentation
¶
Index ¶
- func ActionError(w io.Writer, msg string, opts OutputOptions) error
- func ActionSuccess(w io.Writer) error
- func ComputedStyles(w io.Writer, styles map[string]string) error
- func ComputedStylesMulti(w io.Writer, elements []ipc.ElementWithStyles) error
- func Console(w io.Writer, entries []ipc.ConsoleEntry, opts OutputOptions) error
- func Cookies(w io.Writer, cookies []ipc.Cookie, opts OutputOptions) error
- func EvalResult(w io.Writer, data ipc.EvalData) error
- func FilePath(w io.Writer, path string) error
- func FormatElementIdentifier(meta ipc.ElementMeta, index int) string
- func InlineStyles(w io.Writer, elements []ipc.ElementWithStyles) error
- func MatchedRules(w io.Writer, rules []ipc.CSSMatchedRule) error
- func Network(w io.Writer, entries []ipc.NetworkEntry, opts OutputOptions) error
- func PropertyValue(w io.Writer, value string) error
- func SanitizeIdentifier(s string) string
- func Status(w io.Writer, data ipc.StatusData, opts OutputOptions) error
- func Tab(w io.Writer, data ipc.TabData, opts OutputOptions) error
- func TabError(w io.Writer, errorMsg string, sessions []ipc.PageSession, ...) error
- type OutputOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionError ¶
func ActionError(w io.Writer, msg string, opts OutputOptions) error
ActionError outputs "Error: <message>" for failed action commands.
func ActionSuccess ¶
ActionSuccess outputs "OK" for successful action commands.
func ComputedStyles ¶
ComputedStyles outputs computed styles in text format. Format: property: value (one per line)
func ComputedStylesMulti ¶
func ComputedStylesMulti(w io.Writer, elements []ipc.ElementWithStyles) error
ComputedStylesMulti outputs computed styles for multiple elements. Each element is identified by a CSS selector-style identifier (#id, .class:N, or tag:N) printed on a separate line before its styles. Multiple elements are separated by "--".
Format:
#header color: blue font-size: 16px -- .panel:2 background: white
Elements are identified by priority: ID > first class > tag name. Index numbers are 1-based for user readability.
func Console ¶
func Console(w io.Writer, entries []ipc.ConsoleEntry, opts OutputOptions) error
Console outputs console entries in text format.
func EvalResult ¶
EvalResult outputs the raw JavaScript return value.
func FormatElementIdentifier ¶
func FormatElementIdentifier(meta ipc.ElementMeta, index int) string
FormatElementIdentifier returns a CSS selector-style identifier for an element. The identifier helps users distinguish between multiple elements in output.
Format:
- #id if element has id attribute
- .class:N if element has class attribute (N is 1-based index)
- tag:N fallback using tag name (N is 1-based index)
The index parameter is 0-based but displayed as 1-based (index+1) for user-friendliness. IDs and classes are sanitized to remove invalid CSS identifier characters. If sanitization results in an empty string, the next priority level is used.
Examples:
- Element with id="header" -> "#header"
- Element with class="panel active" at index 0 -> ".panel:1"
- Element with tag "div" at index 2 -> "div:3"
func InlineStyles ¶
func InlineStyles(w io.Writer, elements []ipc.ElementWithStyles) error
InlineStyles outputs inline style attributes for multiple elements. Each element is identified by a CSS selector-style identifier (#id, .class:N, or tag:N) printed on a separate line before its inline style. Multiple elements are separated by "--". Empty inline styles are displayed as "(empty)".
Format:
#main color: red; margin: 10px; -- .item:1 (empty)
Elements are identified by priority: ID > first class > tag name. Index numbers are 1-based for user readability.
func MatchedRules ¶
func MatchedRules(w io.Writer, rules []ipc.CSSMatchedRule) error
MatchedRules outputs matched CSS rules with -- separators.
func Network ¶
func Network(w io.Writer, entries []ipc.NetworkEntry, opts OutputOptions) error
Network outputs network entries in text format.
func PropertyValue ¶
PropertyValue outputs a single CSS property value.
func SanitizeIdentifier ¶
SanitizeIdentifier removes invalid CSS identifier characters. Only alphanumeric characters, hyphens, and underscores are retained. Returns an empty string if no valid characters remain.
This function is used to clean id and class attributes before using them in CSS selector notation. Invalid characters are stripped to ensure the resulting identifier is valid CSS.
func Status ¶
func Status(w io.Writer, data ipc.StatusData, opts OutputOptions) error
Status outputs daemon status in text format.
func TabError ¶ added in v0.1.0
func TabError(w io.Writer, errorMsg string, sessions []ipc.PageSession, matches []ipc.PageSession, opts OutputOptions) error
TabError outputs a tab error with session/match information.
Types ¶
type OutputOptions ¶
type OutputOptions struct {
UseColor bool // Enable ANSI color codes
}
OutputOptions controls text formatting behavior.
func DefaultOptions ¶
func DefaultOptions() OutputOptions
DefaultOptions returns default output options based on TTY detection. Deprecated: Use NewOutputOptions instead for proper color detection.
func NewOutputOptions ¶
func NewOutputOptions(jsonOutput bool, noColorFlag bool) OutputOptions
NewOutputOptions returns output options based on flags and environment. Priority: jsonOutput > noColorFlag > NO_COLOR env > TTY detection.