arguments

package
v0.35.3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddKeyValuePFlag

func AddKeyValuePFlag(cmd *cobra.Command, field *map[string]string, name, shorthand string, value []string, usage string)

AddKeyValuePFlag adds a flag to the command that accepts a (possibly repeated) key=value pair.

func AskForUserFields

func AskForUserFields(userFields []*rpc.UserField) (map[string]string, error)

AskForUserFields prompts the user to input the provided user fields. If there is an error reading input it panics.

func CalculateFQBNAndPort

func CalculateFQBNAndPort(portArgs *Port, fqbnArg *Fqbn, instance *rpc.Instance, defaultFQBN, defaultAddress, defaultProtocol string) (string, *rpc.Port)

CalculateFQBNAndPort calculate the FQBN and Port metadata based on parameters provided by the user. This determine the FQBN based on: - the value of the FQBN flag if explicitly specified, otherwise - the default FQBN value in sketch.yaml (`default_fqbn` key) if available, otherwise - it tries to autodetect the board connected to the given port flags If all above methods fails, it returns the empty string. The Port metadata are always returned except if:

  • the port is not found, in this case nil is returned
  • the FQBN autodetection fail, in this case the function prints an error and terminates the execution

func CheckFlagsConflicts

func CheckFlagsConflicts(command *cobra.Command, flagNames ...string)

CheckFlagsConflicts is a helper function useful to report errors when more than one conflicting flag is used

func CheckFlagsMandatory

func CheckFlagsMandatory(command *cobra.Command, flagNames ...string)

CheckFlagsMandatory is a helper function useful to report errors when at least one flag is not used in a group of "required" flags

func GetAvailablePorts

func GetAvailablePorts() []*rpc.Port

GetAvailablePorts is an helper function useful to autocomplete. It returns a list of upload port of the boards which are currently connected. It will not suggests network ports because the timeout is not set.

func GetInstallableCores

func GetInstallableCores() []string

GetInstallableCores is an helper function useful to autocomplete. It returns a list of cores which can be installed/downloaded

func GetInstallableLibs

func GetInstallableLibs() []string

GetInstallableLibs is an helper function useful to autocomplete. It returns a list of libs which can be installed/downloaded

func GetInstalledBoards

func GetInstalledBoards() []string

GetInstalledBoards is an helper function useful to autocomplete. It returns a list of fqbn it's taken from cli/board/listall.go

func GetInstalledLibraries

func GetInstalledLibraries() []string

GetInstalledLibraries is an helper function useful to autocomplete. It returns a list of libs which are currently installed, including the builtin ones

func GetInstalledProgrammers

func GetInstalledProgrammers() []string

GetInstalledProgrammers is an helper function useful to autocomplete. It returns a list of programmers available based on the installed boards

func GetUninstallableCores

func GetUninstallableCores() []string

GetUninstallableCores is an helper function useful to autocomplete. It returns a list of cores which can be uninstalled

func GetUninstallableLibraries

func GetUninstallableLibraries() []string

GetUninstallableLibraries is an helper function useful to autocomplete. It returns a list of libs which can be uninstalled

func InitSketchPath

func InitSketchPath(path string) (sketchPath *paths.Path)

InitSketchPath returns an instance of paths.Path pointing to sketchPath. If sketchPath is an empty string returns the current working directory. In both cases it warns the user if he's using deprecated files

Types

type DiscoveryTimeout

type DiscoveryTimeout struct {
	// contains filtered or unexported fields
}

DiscoveryTimeout is the timeout given to discoveries to detect ports.

func (*DiscoveryTimeout) AddToCommand

func (d *DiscoveryTimeout) AddToCommand(cmd *cobra.Command)

AddToCommand adds the flags used to set fqbn to the specified Command

func (*DiscoveryTimeout) Get

func (d *DiscoveryTimeout) Get() time.Duration

Get returns the timeout

type Fqbn

type Fqbn struct {
	// contains filtered or unexported fields
}

Fqbn contains the fqbn flag data. This is useful so all flags used by commands that need this information are consistent with each other.

func (*Fqbn) AddToCommand

func (f *Fqbn) AddToCommand(cmd *cobra.Command)

AddToCommand adds the flags used to set fqbn to the specified Command

func (*Fqbn) Set

func (f *Fqbn) Set(fqbn string)

Set sets the fqbn

func (*Fqbn) String

func (f *Fqbn) String() string

String returns the fqbn with the board options if there are any

type Port

type Port struct {
	// contains filtered or unexported fields
}

Port contains the port arguments result. This is useful so all flags used by commands that need this information are consistent with each other.

func (*Port) AddToCommand

func (p *Port) AddToCommand(cmd *cobra.Command)

AddToCommand adds the flags used to set port and protocol to the specified Command

func (*Port) DetectFQBN

func (p *Port) DetectFQBN(inst *rpc.Instance) (string, *rpc.Port)

DetectFQBN tries to identify the board connected to the port and returns the discovered Port object together with the FQBN. If the port does not match exactly 1 board,

func (*Port) GetPort

func (p *Port) GetPort(instance *rpc.Instance, defaultAddress, defaultProtocol string) (*rpc.Port, error)

GetPort returns the Port obtained by parsing command line arguments. The extra metadata for the ports is obtained using the pluggable discoveries.

func (*Port) GetPortAddressAndProtocol

func (p *Port) GetPortAddressAndProtocol(instance *rpc.Instance, defaultAddress, defaultProtocol string) (string, string, error)

GetPortAddressAndProtocol returns only the port address and the port protocol without any other port metadata obtained from the discoveries. This method allows will bypass the discoveries if: - a nil instance is passed: in this case the plain port and protocol arguments are returned (even if empty) - a protocol is specified: in this case the discoveries are not needed to autodetect the protocol.

func (*Port) GetSearchTimeout

func (p *Port) GetSearchTimeout() time.Duration

GetSearchTimeout returns the timeout

type PrePostScriptsFlags

type PrePostScriptsFlags struct {
	// contains filtered or unexported fields
}

PrePostScriptsFlags contains flags data used by the core install and the upgrade command This is useful so all flags used by commands that need this information are consistent with each other.

func (*PrePostScriptsFlags) AddToCommand

func (p *PrePostScriptsFlags) AddToCommand(cmd *cobra.Command)

AddToCommand adds flags that can be used to force running or skipping of post installation scripts

func (*PrePostScriptsFlags) DetectSkipPostInstallValue

func (p *PrePostScriptsFlags) DetectSkipPostInstallValue() bool

DetectSkipPostInstallValue returns true if a post install script must be run

func (*PrePostScriptsFlags) DetectSkipPreUninstallValue

func (p *PrePostScriptsFlags) DetectSkipPreUninstallValue() bool

DetectSkipPreUninstallValue returns true if a post install script must be run

func (*PrePostScriptsFlags) GetRunPostInstall

func (p *PrePostScriptsFlags) GetRunPostInstall() bool

GetRunPostInstall returns the run-post-install flag value

func (*PrePostScriptsFlags) GetRunPreUninstall

func (p *PrePostScriptsFlags) GetRunPreUninstall() bool

GetRunPreUninstall returns the run-post-install flag value

func (*PrePostScriptsFlags) GetSkipPostInstall

func (p *PrePostScriptsFlags) GetSkipPostInstall() bool

GetSkipPostInstall returns the skip-post-install flag value

func (*PrePostScriptsFlags) GetSkipPreUninstall

func (p *PrePostScriptsFlags) GetSkipPreUninstall() bool

GetSkipPreUninstall returns the skip-post-install flag value

type Profile

type Profile struct {
	// contains filtered or unexported fields
}

Profile contains the profile flag data. This is useful so all flags used by commands that need this information are consistent with each other.

func (*Profile) AddToCommand

func (f *Profile) AddToCommand(cmd *cobra.Command)

AddToCommand adds the flags used to set fqbn to the specified Command

func (*Profile) Get

func (f *Profile) Get() string

Get returns the profile name

func (*Profile) Set

func (f *Profile) Set(profile string)

Set sets the profile

func (*Profile) String

func (f *Profile) String() string

String returns the profile name

type Programmer

type Programmer struct {
	// contains filtered or unexported fields
}

Programmer contains the programmer flag data. This is useful so all flags used by commands that need this information are consistent with each other.

func (*Programmer) AddToCommand

func (p *Programmer) AddToCommand(cmd *cobra.Command)

AddToCommand adds the flags used to set the programmer to the specified Command

func (*Programmer) String

func (p *Programmer) String(inst *commands.Instance, fqbn string) string

String returns the programmer specified by the user, or the default programmer for the given board if defined.

type Reference

type Reference struct {
	PackageName  string
	Architecture string
	Version      string
}

Reference represents a reference item (core or library) passed to the CLI interface

func ParseReference

func ParseReference(arg string) (*Reference, error)

ParseReference parses a string and returns a Reference object. It tries to infer the platform the user is asking for. To achieve that, it tries to use github.com/arduino/arduino-cli/commands/core.GetPlatform Note that the Reference is returned rightaway if the arg inserted by the user matches perfectly one in the response of core.GetPlatform A MultiplePlatformsError is returned if the platform searched by the user matches multiple platforms

func ParseReferences

func ParseReferences(args []string) ([]*Reference, error)

ParseReferences is a convenient wrapper that operates on a slice of strings and calls ParseReference for each of them. It returns at the first invalid argument.

func (*Reference) String

func (r *Reference) String() string

type ShowProperties

type ShowProperties struct {
	// contains filtered or unexported fields
}

ShowProperties represents the --show-properties flag.

func (*ShowProperties) AddToCommand

func (p *ShowProperties) AddToCommand(command *cobra.Command)

AddToCommand adds the --show-properties flag to the specified command.

func (*ShowProperties) Get

Get returns the corresponding ShowProperties value.

type ShowPropertiesMode

type ShowPropertiesMode int

ShowPropertiesMode represents the possible values of the --show-properties flag.

const (
	// ShowPropertiesDisabled means that the --show-properties flag has not been used
	ShowPropertiesDisabled ShowPropertiesMode = iota
	// ShowPropertiesUnexpanded means that the --show-properties flag has been used without a value or with the value "unexpanded"
	ShowPropertiesUnexpanded
	// ShowPropertiesExpanded means that the --show-properties flag has been used with the value "expanded"
	ShowPropertiesExpanded
)

Jump to

Keyboard shortcuts

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