format

package
v3.0.0-pre-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package format provides formatting fuctions for different output format types.

Index

Constants

This section is empty.

Variables

View Source
var Converters = make(map[Type]func(opts ...Option) Formatter)
View Source
var Descriptions = map[Type]string{
	CText: "Plain text format",
	CCSV:  "CSV format",
	CJSON: "JSON format",
}

Functions

func NVL

func NVL(s string, rest ...string) string

Types

type CSV

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

func (*CSV) Channels

func (c *CSV) Channels(ctx context.Context, w io.Writer, u []slack.User, chans []slack.Channel) error

func (*CSV) Conversation

func (c *CSV) Conversation(ctx context.Context, w io.Writer, u []slack.User, conv *types.Conversation) error

func (*CSV) Users

func (c *CSV) Users(ctx context.Context, w io.Writer, users []slack.User) error

type Formatter

type Formatter interface {
	Conversation(ctx context.Context, w io.Writer, u []slack.User, conv *types.Conversation) error
	Channels(ctx context.Context, w io.Writer, u []slack.User, chans []slack.Channel) error
	Users(ctx context.Context, w io.Writer, u []slack.User) error
}

Formatter is a converter interface that each formatter must implement.

func NewCSV

func NewCSV(opts ...Option) Formatter

func NewJSON

func NewJSON(opts ...Option) Formatter

func NewText

func NewText(opts ...Option) Formatter

type JSON

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

JSON is the json formatter.

func (JSON) Channels

func (j JSON) Channels(ctx context.Context, w io.Writer, u []slack.User, chans []slack.Channel) error

func (JSON) Conversation

func (j JSON) Conversation(ctx context.Context, w io.Writer, u []slack.User, conv *types.Conversation) error

func (JSON) Users

func (j JSON) Users(ctx context.Context, w io.Writer, u []slack.User) error

type Option

type Option func(*options)

Option is the converter option.

func JSONIndent

func JSONIndent(indent string) Option

func JSONPrefix

func JSONPrefix(prefix string) Option

func TextNewMessageThreshold

func TextNewMessageThreshold(d time.Duration) Option

type Text

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

func (*Text) Channels

func (txt *Text) Channels(ctx context.Context, w io.Writer, u []slack.User, cc []slack.Channel) error

func (*Text) Conversation

func (txt *Text) Conversation(ctx context.Context, w io.Writer, u []slack.User, conv *types.Conversation) error

func (*Text) Users

func (txt *Text) Users(ctx context.Context, w io.Writer, u []slack.User) error

type Type

type Type int

Type is the converter type.

const (
	CUnknown Type = iota // Unknown converter type
	CText                // CText is the plain text converter
	CCSV                 // CCSV is the CSV converter
	CJSON                // CJSON is JSON format converter
)

func (*Type) Set

func (e *Type) Set(v string) error

func (Type) String

func (i Type) String() string

type Types

type Types []Type

Types is a list of converter types.

func All

func All() Types

func (Types) String

func (tt Types) String() string

Jump to

Keyboard shortcuts

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