package
0.0.0-20181213094507-0031c6d985d6
Repository: https://github.com/facchinm/arduino-cli.git
Documentation: pkg.go.dev

# README

:source-highlighter: pygments :pygments-style: manni

= Output Package Alessandro Sanino [email protected]

This package provides structs and helpers to be used in the rest of the project.

Usually it is paired to link:../https://github.com/bcmi-labs/arduino-cli/common/formatter[Formatter Package]

== Output structs Any Output struct must implement a set of functions, depending on the formatter.

In the case of TextFormatter and JSONFormatter. [source, go]

String() string // For Text Formatter. marshalJSON() ([]byte, error) // For JSON formatter.

Normally marshalJSON() is already implemented using JSON Go Tags if using structs.

=== Example of correct output structs This is a correct example about how to build an output struct:

[source, go]

// ExampleOutput is a struct which implements Formattable // JSON tags are used automatically by marshalJSON. type ExampleOutput struct { ExampleOfField interface{} json:"exampleOfField" ExampleOfAnotherField int json:"ExampleOfAnotherField" ExampleOfRequiredField string json:"ExampleOfRequiredField,required" ExampleOfOptionalField string json:"ExampleOfOptionalField,omitempty" }

// String() is used by fmt.Printf, fmt.Sprintf, fmt.Fprintf families of functions, // and TextFormatter. func (eo ExampleOutput) String() string { ret := fmt.Sprintln("ExampleOfField:", eo.ExampleOfField) ret += fmt.Sprintln("ExampleOfAnotherField:", eo.ExampleOfAnotherField) ret += fmt.Sprintln("ExampleOfRequiredField (error if not set):", eo.ExampleOfRequiredField) // Do not show optional fields. if eo.ExampleOfOptionalField != "" { ret += fmt.Sprintln("ExampleOfOptionalField (may not appear if not set):", eo.ExampleOfField) } // Print that required variable is missing. if eo.ExampleOfRequiredField == "" { ret += fmt.Sprintln("WARNING : Required field ExampleOfRequiredField is not set") } return ret }

# Structs

AttachedBoardList is a list of attached boards.
BoardList is a list of supported boards.
BoardListItem is a supported board.
CoreProcessResults represent the result of a process on cores or tools.
InstalledLibary is an installed library.
InstalledLibraries is a list of installed libraries.
InstalledPlatform represents an output of an installed plaform.
InstalledPlatforms represents an output of a set of installed platforms.
LibProcessResults represent the result of a process on libraries.
LibSearchResults represents a set of results of a search of libraries.
NetworkBoardListItem represents a board connected via network.
ProcessResult contains info about a completed process.
SearchedPlatform represents an output of a searched platform.
SearchedPlatforms represents an output of a set of searched platforms.
SerialBoardListItem represents a board connected using serial port.
SketchSyncError represents an error during a `arduino sketch sync` operation.
SketchSyncResult contains the result of an `arduino sketch sync` operation.
VersionResult represents the output of the version commands.