jsonout

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package jsonout lets a command print its result as one JSON document on stdout, for programs that run compa-kernel: the command's --json flag.

Index

Constants

View Source
const Flag = "json"

Flag is the name of the flag that asks for JSON.

View Source
const Usage = "Print the result as one JSON document"

Usage describes the flag in help.

Variables

This section is empty.

Functions

func Accepted

func Accepted(cmd *cobra.Command) bool

Accepted reports whether cmd has the --json flag.

func InArgs

func InArgs(args []string) bool

InArgs reports whether args, the command line without the program, ask for --json. main decides with it what it does before the flags are parsed: whether to print the banner, and where the logs go.

func Progress

func Progress(cmd *cobra.Command) io.Writer

Progress is where cmd writes prompts and progress: stdout, or stderr when stdout carries the JSON document.

func Requested

func Requested(cmd *cobra.Command) bool

Requested reports whether cmd runs with --json.

func Write

func Write(w io.Writer, v any) error

Write prints v as one indented JSON document.

func WriteError

func WriteError(w io.Writer, err error) error

WriteError prints the document of a failed command: {"error": message}.

Types

This section is empty.

Jump to

Keyboard shortcuts

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