cli

package
v3.35.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0, Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package cli contains a FeatureBase command line interface.

Index

Constants

View Source
const (
	ErrOrganizationRequired errors.Code = "OrganizationRequired"
)

Variables

View Source
var (
	Stdin  io.ReadCloser = os.Stdin
	Stdout io.Writer     = os.Stdout
	Stderr io.Writer     = os.Stderr
)

Functions

func NewErrOrganizationRequired added in v3.34.0

func NewErrOrganizationRequired() error

Types

type CloudAuthConfig added in v3.33.0

type CloudAuthConfig struct {
	ClientID string `json:"client-id"`
	Region   string `json:"region"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

type Command added in v3.33.0

type Command struct {
	Queryer Queryer `json:"-"`

	Config *Config `json:"config"`

	// Commands contains optional commands provided via one or more `-c` (or
	// `--command`) flags. If this is non-empty, the cli will run in
	// non-interactive mode; i.e. it will quit after the command is complete.
	Commands []string `json:"commands"`

	// Files contains optional files provided via one or more `-f` (or `--file`)
	// flags. If this is non-empty, the cli will run in non-interactive mode;
	// i.e. it will quit after the command is complete.
	Files []string `json:"files"`
	// contains filtered or unexported fields
}

func NewCommand added in v3.33.0

func NewCommand(logdest logger.Logger) *Command

func (*Command) Errorf added in v3.33.0

func (cmd *Command) Errorf(format string, a ...any)

Errorf is a helper method which sends the given payload to stderr.

func (*Command) Insert added in v3.34.0

func (cmd *Command) Insert(sql string) error

func (*Command) Outputf added in v3.33.0

func (cmd *Command) Outputf(format string, a ...any)

Outputf is a helper method which sends the given payload to output.

func (*Command) Printf added in v3.33.0

func (cmd *Command) Printf(format string, a ...any)

Printf is a helper method which sends the given payload to stdout.

func (*Command) Run added in v3.33.0

func (cmd *Command) Run(ctx context.Context) error

Run is the main entry-point to the CLI.

func (*Command) SetStderr added in v3.34.0

func (cmd *Command) SetStderr(w io.Writer)

SetStderr sets stderr. This is useful for initial configuration in tests.

func (*Command) SetStdin added in v3.34.0

func (cmd *Command) SetStdin(rc io.ReadCloser)

SetStdin sets stdin. This is useful for initial configuration in tests.

func (*Command) SetStdout added in v3.34.0

func (cmd *Command) SetStdout(w io.Writer)

SetStdout sets both stdout and output to the value provided. This is useful for initial configuration in tests.

type Config added in v3.33.0

type Config struct {
	Host string `json:"host"`
	Port string `json:"port"`

	OrganizationID string `json:"org-id"`
	Database       string `json:"db"`

	// CloudAuth
	CloudAuth CloudAuthConfig `json:"cloud-auth"`

	// Kafka
	KafkaConfig string `json:"kafka-config"`

	HistoryPath string `json:"history-path"`

	// CSV (Comma-Separated Values) table output mode.
	CSV bool `json:"csv"`

	// PSet takes one or more pset arguments of the form: `--pset=VAR[=ARG]`.
	PSets []string `json:"pset"`
}

Config represents the configuration for the command.

type Queryer

type Queryer interface {
	Query(org string, db string, sql io.Reader) (*featurebase.WireQueryResponse, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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