cli

package
v0.2.39 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: AGPL-3.0 Imports: 37 Imported by: 0

README

[EXPERIMENTAL] Viam Command Line Interface

This is an experimental feature, so things may change without notice.

Install with go build -o ~/go/bin/viam cli/cmd/main.go

Getting Started

Enter viam auth and follow instructions to authenticate.

Documentation

Overview

Package cli contains all business logic needed by the CLI command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppClient

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

The AppClient provides all the CLI command functionality needed to talk to the app service but not directly to robot parts.

func NewAppClient

func NewAppClient(c *cli.Context) (*AppClient, error)

NewAppClient returns a new app client that may already be authenticated.

func (*AppClient) BinaryData added in v0.1.6

func (c *AppClient) BinaryData(dst string, filter *datapb.Filter, parallelDownloads uint) error

BinaryData downloads binary data matching filter to dst.

func (*AppClient) Config

func (c *AppClient) Config() *Config

Config returns the current config.

func (*AppClient) DeleteBinaryData added in v0.2.8

func (c *AppClient) DeleteBinaryData(filter *datapb.Filter) error

DeleteBinaryData deletes binary data matching filter.

func (*AppClient) DeleteTabularData added in v0.2.8

func (c *AppClient) DeleteTabularData(filter *datapb.Filter) error

DeleteTabularData delete tabular data matching filter.

func (*AppClient) ListLocations

func (c *AppClient) ListLocations(orgID string) ([]*apppb.Location, error)

ListLocations returns all locations in the given organizationbelonging to the currently authenticated user.

func (*AppClient) ListOrganizations

func (c *AppClient) ListOrganizations() ([]*apppb.Organization, error)

ListOrganizations returns all organizations belonging to the currently authenticated user.

func (*AppClient) ListRobots

func (c *AppClient) ListRobots(orgStr, locStr string) ([]*apppb.Robot, error)

ListRobots returns all robots in the given location.

func (*AppClient) Login added in v0.2.14

func (c *AppClient) Login() error

Login goes through the CLI login flow using a device code and browser. Once logged in the access token and user details are cached on disk.

func (*AppClient) Logout

func (c *AppClient) Logout() error

Logout logs out the client and clears the config.

func (*AppClient) PrepareAuthorization

func (c *AppClient) PrepareAuthorization() (string, string, error)

PrepareAuthorization prepares authorization for this device and returns the device token to late authenticate with and the URL to authorize the device at.

func (*AppClient) PrintRobotPartLogs

func (c *AppClient) PrintRobotPartLogs(orgStr, locStr, robotStr, partStr string, errorsOnly bool, indent, header string) error

PrintRobotPartLogs prints logs for the given robot part.

func (*AppClient) RPCOpts

func (c *AppClient) RPCOpts() []rpc.DialOption

RPCOpts returns RPC dial options dervied from the base URL being used in the current invocation of the CLI.

func (*AppClient) Robot

func (c *AppClient) Robot(orgStr, locStr, robotStr string) (*apppb.Robot, error)

Robot returns the given robot.

func (*AppClient) RobotPart

func (c *AppClient) RobotPart(orgStr, locStr, robotStr, partStr string) (*apppb.RobotPart, error)

RobotPart returns the given robot part belonging to a robot.

func (*AppClient) RobotPartLogs

func (c *AppClient) RobotPartLogs(orgStr, locStr, robotStr, partStr string) ([]*apppb.LogEntry, error)

RobotPartLogs returns recent logs for the given robot part.

func (*AppClient) RobotPartLogsErrors

func (c *AppClient) RobotPartLogsErrors(orgStr, locStr, robotStr, partStr string) ([]*apppb.LogEntry, error)

RobotPartLogsErrors returns recent error logs for the given robot part.

func (*AppClient) RobotParts

func (c *AppClient) RobotParts(orgStr, locStr, robotStr string) ([]*apppb.RobotPart, error)

RobotParts returns all parts of the given robot.

func (*AppClient) RunRobotPartCommand

func (c *AppClient) RunRobotPartCommand(
	orgStr, locStr, robotStr, partStr string,
	svcMethod, data string,
	streamDur time.Duration,
	debug bool,
	logger golog.Logger,
) error

RunRobotPartCommand runs the given command on a robot part.

func (*AppClient) SelectedLoc

func (c *AppClient) SelectedLoc() *apppb.Location

SelectedLoc returns the currently selected location, possibly zero initialized.

func (*AppClient) SelectedOrg

func (c *AppClient) SelectedOrg() *apppb.Organization

SelectedOrg returns the currently selected organization, possibly zero initialized.

func (*AppClient) StartRobotPartShell

func (c *AppClient) StartRobotPartShell(
	orgStr, locStr, robotStr, partStr string,
	debug bool,
	logger golog.Logger,
) error

StartRobotPartShell starts a shell on a robot part.

func (*AppClient) TabularData added in v0.1.6

func (c *AppClient) TabularData(dst string, filter *datapb.Filter) error

TabularData downloads binary data matching filter to dst.

func (*AppClient) TailRobotPartLogs

func (c *AppClient) TailRobotPartLogs(orgStr, locStr, robotStr, partStr string, errorsOnly bool, indent, header string) error

TailRobotPartLogs tails and prints logs for the given robot part.

type Config

type Config struct {
	Auth *Token `json:"auth"`
}

Config contains stored config information for the CLI.

type Token added in v0.2.14

type Token struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	IDToken      string    `json:"id_token"`
	ExpiresAt    time.Time `json:"expires_at"`
	TokenType    string    `json:"token_type"`
	TokenURL     string    `json:"token_url"`
	ClientID     string    `json:"client_id"`

	User UserData `json:"user_data"`
}

Token contains an authorization token and details once logged in.

func (*Token) CanRefresh added in v0.2.14

func (t *Token) CanRefresh() bool

CanRefresh returns true if the token can be refreshed.

func (*Token) IsExpired added in v0.2.14

func (t *Token) IsExpired() bool

IsExpired returns true if the token is expired.

type UserData added in v0.2.14

type UserData struct {
	jwt.Claims

	Email   string `json:"email"`
	Subject string `json:"sub"` // userID
}

UserData user details from login.

Directories

Path Synopsis
Package main is the CLI command itself.
Package main is the CLI command itself.

Jump to

Keyboard shortcuts

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