bufprint

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 23 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllFormatsString is the string representation of all Formats.
	AllFormatsString = stringutil.SliceToString([]string{FormatText.String(), FormatJSON.String()})
)

Functions

func WithTabWriter

func WithTabWriter(
	writer io.Writer,
	header []string,
	f func(TabWriter) error,
) (retErr error)

WithTabWriter calls a function with a TabWriter.

Shared with internal packages.

Types

type CommitPrinter added in v1.36.0

type CommitPrinter interface {
	PrintCommitInfo(ctx context.Context, format Format, commit *modulev1.Commit) error
	PrintCommits(ctx context.Context, format Format, commits ...*modulev1.Commit) error
	PrintCommitPage(ctx context.Context, format Format, nextPageCommand, nextPageToken string, commits []*modulev1.Commit) error
}

CommitPrinter is a commit printer.

func NewCommitPrinter added in v1.36.0

func NewCommitPrinter(writer io.Writer, moduleFullName bufmodule.ModuleFullName) CommitPrinter

NewCommitPrinter returns a new RepositoryCommitPrinter.

type CuratedPluginPrinter added in v1.7.0

type CuratedPluginPrinter interface {
	PrintCuratedPlugin(ctx context.Context, format Format, plugin *registryv1alpha1.CuratedPlugin) error
	PrintCuratedPlugins(ctx context.Context, format Format, nextPageToken string, plugins ...*registryv1alpha1.CuratedPlugin) error
}

CuratedPluginPrinter is a printer for curated plugins.

func NewCuratedPluginPrinter added in v1.7.0

func NewCuratedPluginPrinter(writer io.Writer) CuratedPluginPrinter

NewCuratedPluginPrinter returns a new CuratedPluginPrinter.

type Format

type Format int

Format is a format to print.

const (
	// FormatText is the text format.
	FormatText Format = 1
	// FormatJSON is the JSON format.
	FormatJSON Format = 2
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat parses the format.

If the empty string is provided, this is interpreted as FormatText.

func (Format) String

func (f Format) String() string

String implements fmt.Stringer.

type LabelPrinter added in v1.36.0

type LabelPrinter interface {
	// PrintLabels prints each label on a new line.
	PrintLabels(ctx context.Context, format Format, label ...*modulev1.Label) error
	// PrintLabels prints information about a label.
	PrintLabelInfo(ctx context.Context, format Format, label *modulev1.Label) error
	// PrintLabelPage prints a page of labels.
	PrintLabelPage(ctx context.Context, format Format, nextPageCommand, nextPageToken string, labels []*modulev1.Label) error
}

LabelPrinter is a repository label printer.

func NewLabelPrinter added in v1.36.0

func NewLabelPrinter(writer io.Writer, moduleFullName bufmodule.ModuleFullName) LabelPrinter

NewLabelPrinter returns a new RepositoryLabelPrinter.

type ModulePrinter added in v1.36.0

type ModulePrinter interface {
	PrintModuleInfo(ctx context.Context, format Format, repository *modulev1.Module) error
}

ModulePrinter is a module printer.

func NewModulePrinter added in v1.36.0

func NewModulePrinter(
	clientConfig *connectclient.Config,
	address string,
	writer io.Writer,
) ModulePrinter

NewModulePrinter returns a new ModulePrinter.

type OrganizationPrinter

type OrganizationPrinter interface {
	PrintOrganizationInfo(ctx context.Context, format Format, organization *ownerv1.Organization) error
}

OrganizationPrinter is an organization printer.

func NewOrganizationPrinter

func NewOrganizationPrinter(address string, writer io.Writer) OrganizationPrinter

NewOrganizationPrinter returns a new OrganizationPrinter.

type StatsPrinter added in v1.17.0

type StatsPrinter interface {
	PrintStats(ctx context.Context, format Format, stats *protostat.Stats) error
}

StatsPrinter is a printer of Stats.

func NewStatsPrinter added in v1.17.0

func NewStatsPrinter(writer io.Writer) StatsPrinter

NewStatsPrinter returns a new StatsPrinter.

type TabWriter

type TabWriter interface {
	Write(values ...string) error
}

TabWriter is a tab writer.

type TokenPrinter

type TokenPrinter interface {
	PrintTokens(ctx context.Context, tokens ...*registryv1alpha1.Token) error
}

TokenPrinter is a token printer.

TODO: update to same format as other printers.

func NewTokenPrinter

func NewTokenPrinter(writer io.Writer, format Format) (TokenPrinter, error)

NewTokenPrinter returns a new TokenPrinter.

TODO: update to same format as other printers.

Jump to

Keyboard shortcuts

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