cli

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FinishedParsing

func FinishedParsing(cmd *cobra.Command)

FinishedParsing transitions a cobra.Command from treating RunE errors as usage errors to treating them just as normal runtime errors that should be propagated up to the root command's Execute method without also printing the subcommand's usage text on stderr. A subcommand should call this function from its RunE function when it has finished processing its flags and is moving into the pure "business logic" of its entrypoint.

Package vitess.io/vitess/go/cmd/vtctldclient/internal/command has more details on why this exists.

func MarshalJSON

func MarshalJSON(obj any) ([]byte, error)

MarshalJSON marshals obj to a JSON string. It uses the jsonpb marshaler for proto.Message types, with some sensible defaults, and falls back to the standard Go marshaler otherwise. In both cases, the marshaled JSON is indented with two spaces for readability.

Unfortunately jsonpb only works for types that implement proto.Message, either by being a proto message type or by anonymously embedding one, so for other types that may have nested struct fields, we still use the standard Go marshaler, which will result in different formattings.

func MarshalMapAWK

func MarshalMapAWK(m map[string]string) string

MarshalMapAWK returns a string representation of a string->string map in an AWK-friendly format.

func MarshalTabletAWK

func MarshalTabletAWK(t *topodatapb.Tablet) string

MarshalTabletAWK marshals a tablet into an AWK-friendly line.

func ParseKeyspaceShards

func ParseKeyspaceShards(args []string) ([]*vtctldatapb.Shard, error)

ParseKeyspaceShards takes a list of positional arguments and converts them to vtctldatapb.Shard objects.

func TabletAliasesFromPosArgs

func TabletAliasesFromPosArgs(args []string) ([]*topodatapb.TabletAlias, error)

TabletAliasesFromPosArgs takes a list of positional (non-flag) arguments and converts them to tablet aliases.

func WriteQueryResultTable added in v0.14.0

func WriteQueryResultTable(w io.Writer, qr *sqltypes.Result)

WriteQueryResultTable writes a QueryResult as a human-friendly table to the the provided io.Writer.

Types

type KeyspaceTypeFlag

type KeyspaceTypeFlag topodatapb.KeyspaceType

KeyspaceTypeFlag adds the pflag.Value interface to a topodatapb.KeyspaceType.

func (*KeyspaceTypeFlag) Set

func (v *KeyspaceTypeFlag) Set(arg string) error

Set is part of the pflag.Value interface.

func (*KeyspaceTypeFlag) String

func (v *KeyspaceTypeFlag) String() string

String is part of the pflag.Value interface.

func (*KeyspaceTypeFlag) Type

func (v *KeyspaceTypeFlag) Type() string

Type is part of the pflag.Value interface.

type ReplicatingTablet

type ReplicatingTablet struct {
	*replicationdatapb.Status
	*topodatapb.Tablet
}

ReplicatingTablet is a struct to group a Tablet together with its replication Status.

func SortedReplicatingTablets

func SortedReplicatingTablets(tabletMap map[string]*topodatapb.Tablet, replicationStatuses map[string]*replicationdatapb.Status) []*ReplicatingTablet

SortedReplicatingTablets returns a sorted list of replicating tablets (which is a struct grouping a Tablet together with its replication Status).

The sorting order is: 1. Tablets that do not have a replication Status. 2. Any tablets of type PRIMARY. 3. Remaining tablets sorted by comparing replication positions.

type StringMapValue

type StringMapValue struct {
	flagutil.StringMapValue
}

StringMapValue augments flagutil.StringMapValue so it can be used as a pflag.Value.

func (*StringMapValue) Type

func (v *StringMapValue) Type() string

Type is part of the pflag.Value interface.

Jump to

Keyboard shortcuts

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