output

package
v0.0.0-...-0031c6d Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

README

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

= Output Package
Alessandro Sanino <a.sanino@arduino.cc>

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
}
----

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttachedBoardList

type AttachedBoardList struct {
	SerialBoards  []SerialBoardListItem  `json:"serialBoards,required"`
	NetworkBoards []NetworkBoardListItem `json:"networkBoards,required"`
}

AttachedBoardList is a list of attached boards.

func (*AttachedBoardList) String

func (bl *AttachedBoardList) String() string

type BoardList

type BoardList struct {
	Boards []*BoardListItem `json:"boards,required"`
}

BoardList is a list of supported boards

func (*BoardList) Len

func (bl *BoardList) Len() int

func (*BoardList) Less

func (bl *BoardList) Less(i, j int) bool

func (*BoardList) String

func (bl *BoardList) String() string

func (*BoardList) Swap

func (bl *BoardList) Swap(i, j int)

type BoardListItem

type BoardListItem struct {
	Name string `json:"name,required"`
	Fqbn string `json:"fqbn,required"`
}

BoardListItem is a supported board

type CoreProcessResults

type CoreProcessResults struct {
	Cores map[string]ProcessResult `json:"cores,omitempty"`
	Tools map[string]ProcessResult `json:"tools,omitempty"`
}

CoreProcessResults represent the result of a process on cores or tools.

func (CoreProcessResults) String

func (cpr CoreProcessResults) String() string

String returns a string representation of the object.

type InstalledLibary

type InstalledLibary struct {
	Library   *libraries.Library      `json:"library"`
	Available *librariesindex.Release `omitempy,json:"available"`
}

InstalledLibary is an installed library

type InstalledLibraries

type InstalledLibraries struct {
	Libraries []*InstalledLibary `json:"libraries"`
}

InstalledLibraries is a list of installed libraries

func (InstalledLibraries) Len

func (il InstalledLibraries) Len() int

func (InstalledLibraries) Less

func (il InstalledLibraries) Less(i, j int) bool

func (InstalledLibraries) String

func (il InstalledLibraries) String() string

func (InstalledLibraries) Swap

func (il InstalledLibraries) Swap(i, j int)

type InstalledPlatform

type InstalledPlatform struct {
	ID        string
	Installed *semver.Version
	Latest    *semver.Version
	Name      string
}

InstalledPlatform represents an output of an installed plaform.

type InstalledPlatforms

type InstalledPlatforms struct {
	Platforms []*InstalledPlatform
}

InstalledPlatforms represents an output of a set of installed platforms.

func (InstalledPlatforms) String

func (is InstalledPlatforms) String() string

type LibProcessResults

type LibProcessResults struct {
	Libraries map[string]ProcessResult `json:"libraries,required"`
}

LibProcessResults represent the result of a process on libraries.

func (LibProcessResults) Results

func (lpr LibProcessResults) Results() map[string]ProcessResult

Results returns a set of generic results, to allow them to be modified externally.

-> ProcessResults interface.

func (LibProcessResults) String

func (lpr LibProcessResults) String() string

String returns a string representation of the object.

type LibSearchResults

type LibSearchResults struct {
	Libraries []*librariesindex.Library `json:"libraries,required"`
}

LibSearchResults represents a set of results of a search of libraries.

func (LibSearchResults) String

func (lsr LibSearchResults) String() string

String returns a string representation of the object.

type NetworkBoardListItem

type NetworkBoardListItem struct {
	Name     string `json:"name,required"`
	Fqbn     string `json:"fqbn,required"`
	Location string `json:"location,required"`
}

NetworkBoardListItem represents a board connected via network.

type ProcessResult

type ProcessResult struct {
	ItemName string `json:"name,required"`
	Status   string `json:"status,omitempty"`
	Error    string `json:"error,omitempty"`
	Path     string `json:"path,omitempty"`
}

ProcessResult contains info about a completed process.

func (ProcessResult) String

func (lr ProcessResult) String() string

String returns a string representation of the object.

EXAMPLE:
ToolName - ErrorText: Error explaining why failed
ToolName - StatusText: PATH = /path/to/result/dir

type SearchedPlatform

type SearchedPlatform struct {
	ID      string
	Version *semver.Version
	Name    string
}

SearchedPlatform represents an output of a searched platform

type SearchedPlatforms

type SearchedPlatforms struct {
	Platforms []*SearchedPlatform
}

SearchedPlatforms represents an output of a set of searched platforms

func (SearchedPlatforms) String

func (is SearchedPlatforms) String() string

type SerialBoardListItem

type SerialBoardListItem struct {
	Name  string `json:"name,required"`
	Fqbn  string `json:"fqbn,required"`
	Port  string `json:"port,required"`
	UsbID string `json:"usbID,reqiured"`
}

SerialBoardListItem represents a board connected using serial port.

type SketchSyncError

type SketchSyncError struct {
	Sketch string `json:"sketch,required"`
	Error  error  `json:"error,required"`
}

SketchSyncError represents an error during a `arduino sketch sync` operation.

type SketchSyncResult

type SketchSyncResult struct {
	PushedSketches  []string          `json:"pushedSketches,required"`
	PulledSketches  []string          `json:"pulledSketches,required"`
	SkippedSketches []string          `json:"skippedSketches,required"`
	Errors          []SketchSyncError `json:"errors,required"`
}

SketchSyncResult contains the result of an `arduino sketch sync` operation.

func (SketchSyncResult) String

func (ssr SketchSyncResult) String() string

String returns a string representation of the object. For this object it is used to provide verbose info of a sync process.

type VersionResult

type VersionResult struct {
	CommandName string `json:"command,required"`
	Version     string `json:"version,required"`
}

VersionResult represents the output of the version commands.

func (VersionResult) String

func (vr VersionResult) String() string

Jump to

Keyboard shortcuts

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