repotab

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package repotab provides a formatter which show repositories as a table in CLI

Index

Constants

This section is empty.

Variables

View Source
var AttributesCell = CellBuildFunc(func(r gogh.Repository) (content string, style aec.ANSI) {
	contents := []string{""}
	if r.Private {
		style = aec.YellowF
		contents[0] = "private"
	} else {
		style = aec.LightBlackF
		contents[0] = "public"
	}
	if r.Fork {
		contents = append(contents, "fork")
	}
	if r.Archived {
		contents = append(contents, "archived")
	}
	return strings.Join(contents, ","), style
})
View Source
var DefaultColumns = []Column{{
	Priority:    0,
	CellBuilder: SpecCell,
}, {
	Truncatable: true,
	MinWidth:    20,
	Elipsis:     "...",
	Priority:    3,
	CellBuilder: DescriptionCell,
}, {
	Priority:    1,
	CellBuilder: AttributesCell,
}, {
	Align:       AlignRight,
	Priority:    2,
	CellBuilder: UpdatedAtCell,
}}
View Source
var DescriptionCell = CellBuildFunc(func(r gogh.Repository) (content string, style aec.ANSI) {
	content = r.Description
	return content, aec.DefaultF.With(aec.DefaultB)
})
View Source
var EmojiAttributesCell = CellBuildFunc(func(r gogh.Repository) (content string, style aec.ANSI) {

	contents := []string{""}
	if r.Private {
		contents[0] = "\U0001F512\uFE0F "
	} else {
		contents[0] = ""
	}
	if r.Fork {
		contents = append(contents, "\U0001F500\uFE0F ")
	}
	if r.Archived {
		contents = append(contents, "\U0001F5C3\uFE0F ")
	}
	return strings.Join(contents, ""), aec.EmptyBuilder.ANSI
})
View Source
var SpecCell = CellBuildFunc(func(r gogh.Repository) (content string, style aec.ANSI) {
	content = r.Spec.String()
	return content, aec.Bold
})
View Source
var UpdatedAtCell = CellBuildFunc(func(r gogh.Repository) (content string, style aec.ANSI) {
	return view.FuzzyAgoAbbr(time.Now(), r.UpdatedAt), aec.LightBlackF
})

Functions

This section is empty.

Types

type Align

type Align int
const (
	AlignLeft  Align = iota
	AlignRight Align = iota
)

type CellBuildFunc

type CellBuildFunc func(r gogh.Repository) (content string, style aec.ANSI)

func (CellBuildFunc) Build

func (f CellBuildFunc) Build(r gogh.Repository) (content string, style aec.ANSI)

type CellBuilder

type CellBuilder interface {
	Build(gogh.Repository) (content string, style aec.ANSI)
}

type Column

type Column struct {
	CellBuilder CellBuilder
	Elipsis     string
	MinWidth    int
	Priority    int
	Align       Align
	Truncatable bool
	// contains filtered or unexported fields
}

type Option

type Option func(*Printer)

func Columns

func Columns(columns ...Column) Option

func Styled

func Styled() Option

func Width

func Width(w int) Option

type Printer

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

func NewPrinter

func NewPrinter(w io.Writer, option ...Option) *Printer

func (*Printer) Close

func (p *Printer) Close() error

func (*Printer) Print

func (p *Printer) Print(r gogh.Repository) error

Jump to

Keyboard shortcuts

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