Movatterモバイル変換


[0]ホーム

URL:


feedback

package
v1.3.1Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2025 License:GPL-3.0Imports:16Imported by:0

Details

Repository

github.com/arduino/arduino-cli

Links

Documentation

Overview

Package feedback provides an uniform API that can be used toprint feedback to the users in different formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcDirectStreams

func DirectStreams() (io.Writer,io.Writer,error)

DirectStreams returns the underlying io.Writer to directly stream tostdout and stderr.If the selected output format is not Text, the function will error.

Using the streams returned by this function allows direct control ofthe output and the PrintResult function must not be used anymore

funcExitWhenParentProcessEnds

func ExitWhenParentProcessEnds()

ExitWhenParentProcessEnds waits until the controlling parent process ends and then exitsthe current process. This is useful to terminate the current process when it is daemonizedand the controlling parent process is terminated to avoid leaving zombie processes.It is recommended to call this function as a goroutine.

funcFatal

func Fatal(errorMsgstring, exitCodeExitCode)

Fatal outputs the errorMsg and exits with status exitCode.

funcFatalError

func FatalError(errerror, exitCodeExitCode)

FatalError outputs the error and exits with status exitCode.

funcFatalResult

func FatalResult(resErrorResult, exitCodeExitCode)

FatalResult outputs the result and exits with status exitCode.

funcHasConsoleadded inv1.0.0

func HasConsole()bool

HasConsole returns true if the CLI outputs to a terminal/console

funcInputUserField

func InputUserField(promptstring, secretbool) (string,error)

InputUserField prompts the user to input the provided user field.

funcInteractiveStreams

func InteractiveStreams() (io.Reader,io.Writer,error)

InteractiveStreams returns the underlying io.Reader and io.Writer to directly stream tostdin and stdout. It errors if the selected output format is not Text or the terminal isnot interactive.

funcIsCIadded inv1.0.0

func IsCI()bool

IsCI returns true if running on CI environments.(based onhttps://github.com/watson/ci-info/blob/HEAD/index.js)

funcIsInteractiveadded inv1.0.0

func IsInteractive()bool

IsInteractive returns true if the CLI is interactive (it can receive inputs from terminal/console)

funcNewBufferedStreams

func NewBufferedStreams() (io.Writer,io.Writer, func() *OutputStreamsResult)

NewBufferedStreams returns a pair of io.Writer to buffer the command output.The returned writers will accumulate the output until the commandexecution is completed. The io.Writes will not affect other feedback streams.

This function returns also a callback that must be called when thecommand execution is completed, it will return an *OutputStreamsResultobject that can be used as a Result or to retrieve the accumulated outputto embed it in another object.

funcNewCommand

func NewCommand() *cobra.Command

NewCommand creates a new `feedback` command

funcNewDownloadProgressBarCB

func NewDownloadProgressBarCB() func(*rpc.DownloadProgress)

NewDownloadProgressBarCB creates a progress bar callback that outputs a progressbar on the terminal

funcNewTaskProgressCB

func NewTaskProgressCB() func(curr *rpc.TaskProgress)

NewTaskProgressCB returns a commands.TaskProgressCB progress listenerthat outputs to terminal

funcOutputStreams

func OutputStreams() (io.Writer,io.Writer, func() *OutputStreamsResult)

OutputStreams returns a pair of io.Writer to write the command output.The returned writers will accumulate the output until the commandexecution is completed, so they are not suitable for printing an unboundedstream like a debug logger or an event watcher (use DirectStreams forthat purpose).

If the output format is Text the output will be directly streamed to theunderlying stdio streams in real time.

This function returns also a callback that must be called when thecommand execution is completed, it will return an *OutputStreamsResultobject that can be used as a Result or to retrieve the accumulated outputto embed it in another object.

funcPrint

func Print(vstring)

Print behaves like fmt.Print but writes on the out writer and adds a newline.

funcPrintResult

func PrintResult(resResult)

PrintResult is a convenient wrapper to provide feedback for complex data,where the contents can't be just serialized to JSON but requires morestructure.

funcPrintf

func Printf(formatstring, v ...interface{})

Printf behaves like fmt.Printf but writes on the out writer and adds a newline.

funcProgressBar

func ProgressBar()rpc.DownloadProgressCB

ProgressBar returns a DownloadProgressCB that prints a progress bar.

funcRestoreModeStdin

func RestoreModeStdin()

RestoreModeStdin restore the terminal settings to the normal non-RAW state. Thisfunction must be called after SetRawModeStdin to not leave the terminal in anundefined state.

funcSetErr

func SetErr(errio.Writer)

SetErr can be used to change the err writer at runtime

funcSetFormat

func SetFormat(fOutputFormat)

SetFormat can be used to change the output format at runtime

funcSetOut

func SetOut(outio.Writer)

SetOut can be used to change the out writer at runtime

funcSetRawModeStdin

func SetRawModeStdin()error

SetRawModeStdin sets the stdin stream in RAW mode (no buffering, echo disabled,no terminal escape codes nor signals interpreted)

funcTaskProgress

func TaskProgress()rpc.TaskProgressCB

TaskProgress returns a TaskProgressCB that prints the task progress.

funcWarnAboutDeprecatedFilesadded inv1.0.0

func WarnAboutDeprecatedFiles(s *rpc.Sketch)

WarnAboutDeprecatedFiles warns the user that a type of sketch files are deprecated

funcWarning

func Warning(msgstring)

Warning outputs a warning message.

Types

typeErrorResult

type ErrorResult interface {ResultErrorString()string}

ErrorResult is a result embedding also an error. In case of textual outputthe error will be printed on stderr.

typeExitCode

type ExitCodeint

ExitCode to be used for Fatal.

const (// Success (0 is the no-error return code in Unix)SuccessExitCode =iota// ErrGeneric Generic error (1 is the reserved "catchall" code in Unix)ErrGeneric// ErrNoConfigFile is returned when the config file is not found (3)ErrNoConfigFile// ErrNetwork is returned when a network error occurs (5)ErrNetwork// ErrCoreConfig represents an error in the cli core config, for example some basic// files shipped with the installation are missing, or cannot create or get basic// directories vital for the CLI to work. (6)ErrCoreConfig// ErrBadArgument is returned when the arguments are not valid (7)ErrBadArgument// ErrFailedToListenToTCPPort is returned if the CLI failed to open a TCP port// to listen for incoming connections (8)ErrFailedToListenToTCPPort// ErrBadTCPPortArgument is returned if the TCP port argument is not valid (9)ErrBadTCPPortArgument// ErrInitializingInventory is returned when the inventory cannot be initialized,// usually depends on a wrong configuration of the data dir (10)ErrInitializingInventory// ErrMissingProgrammer is returned when the programmer argument is missing (11)ErrMissingProgrammer)

typeOutputFormat

type OutputFormatint

OutputFormat is an output format

const (// Text is the plain text format, suitable for interactive terminalsTextOutputFormat =iota// JSON formatJSON// MinifiedJSON formatMinifiedJSON)

funcGetFormat

func GetFormat()OutputFormat

GetFormat returns the output format currently set

funcParseOutputFormat

func ParseOutputFormat(instring) (OutputFormat,bool)

ParseOutputFormat parses a string and returns the corresponding OutputFormat.The boolean returned is true if the string was a valid OutputFormat.

func (OutputFormat)String

func (fOutputFormat) String()string

typeOutputStreamsResult

type OutputStreamsResult struct {Stdoutstring `json:"stdout"`Stderrstring `json:"stderr"`}

OutputStreamsResult contains the accumulated stdout and stderr outputwhen the selected output format is not Text.

func (*OutputStreamsResult)Data

func (r *OutputStreamsResult) Data() interface{}

Data returns the result object itself, it is used to implement the Result interface.

func (*OutputStreamsResult)Empty

func (r *OutputStreamsResult) Empty()bool

Empty returns true if both Stdout and Stderr are empty.

func (*OutputStreamsResult)String

func (r *OutputStreamsResult) String()string

typeResult

type Result interface {fmt.StringerData() interface{}}

Result is anything more complex than a sentence that needs to be printedfor the user.

Source Files

View all Source files

Directories

PathSynopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp