cli

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: GPL-3.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// 3-4 bits color
	NC      string = "\033[0m"
	BLACK          = "\033[0;30m"
	RED            = "\033[0;31m"
	GREEN          = "\033[0;32m"
	YELLOW         = "\033[0;33m"
	BLUE           = "\033[0;34m"
	MAGENTA        = "\033[0;35m"
	CYAN           = "\033[0;36m"
	WHITE          = "\033[0;37m"
	// RGB colors
	GREY = "\033[0;38;2;128;128;128m"
)

Variables

View Source
var (
	ERROR   = LoggerOptions{Badge: " ✖", Color: RED}
	WARNING = LoggerOptions{Badge: " ⚠", Color: YELLOW}
	SUCCESS = LoggerOptions{Badge: " ✔", Color: GREEN}
)

Functions

func BulkFunc

func BulkFunc(ids []int, successMsgPrefix string, renderer Renderer, c *cli.Context, mapperFunc MapFunction) error

func CaptureOutput

func CaptureOutput(f func()) string

func Difference

func Difference(a, b time.Time) (year, month, day, hour, min, sec int)

func GetCliApp

func GetCliApp(config AppConfig) *cli.App

func GetDurationText

func GetDurationText(a, b time.Time) string

func GroupByCreationDate

func GroupByCreationDate(item entities.Manageable) string

func GroupByStatus

func GroupByStatus(item entities.Manageable) string

func GroupByTag

func GroupByTag(item entities.Manageable) string

func Main

func Main()

Types

type AppConfig

type AppConfig struct {
	DataDirectory         string `json:"data_directory"`
	DisplayCompletedTasks bool   `json:"display_completed_tasks"`
	DefaultDisplayMode    string `json:"default_display_mode"`
}

func GetAppConfig

func GetAppConfig(path string, defaultDataDir string) AppConfig

type COLOR

type COLOR string

func GetColorStatus

func GetColorStatus(min, max, i int) COLOR

type ConsoleRenderer

type ConsoleRenderer struct{}

func (*ConsoleRenderer) Colorify

func (Logger *ConsoleRenderer) Colorify(message interface{}, color COLOR) string

func (*ConsoleRenderer) Error

func (Logger *ConsoleRenderer) Error(message string) error

func (*ConsoleRenderer) Log

func (Logger *ConsoleRenderer) Log(option LoggerOptions, message string) error

func (*ConsoleRenderer) Success

func (Logger *ConsoleRenderer) Success(message string) error

func (*ConsoleRenderer) Warning

func (Logger *ConsoleRenderer) Warning(message string) error

type GetKey

type GetKey func(item entities.Manageable) string

type ItemGroup

type ItemGroup struct {
	Name  string
	Items entities.ItemCollection
}

func GroupBy

func GroupBy(items entities.ItemCollection, keyFunc GetKey) []ItemGroup

func (*ItemGroup) Print

func (g *ItemGroup) Print(renderer Renderer, summarizer ItemSummarizer)

type ItemPresenter

type ItemPresenter interface {
	TimelineView(items entities.ItemCollection) error
	BoardView(items entities.ItemCollection) error
}

func NewItemPresenter

func NewItemPresenter(renderer Renderer) ItemPresenter

type ItemSummarizer

type ItemSummarizer func(item entities.Manageable) string

type LoggerOptions

type LoggerOptions struct {
	Badge string
	Color COLOR
}

type MapFunction

type MapFunction func(id int, c *cli.Context) error

type Renderer

type Renderer interface {
	Colorify(message interface{}, color COLOR) string
	Log(option LoggerOptions, message string) error
	Error(message string) error
	Warning(message string) error
	Success(message string) error
}

func NewRenderer

func NewRenderer() Renderer

type Summary

type Summary struct {
	TasksCount      int
	DoneCount       int
	InProgressCount int
	PendingCount    int
	NoteCount       int
}

func Summarize

func Summarize(items entities.ItemCollection) Summary

func (*Summary) GetDonePercentage

func (s *Summary) GetDonePercentage() float32

Jump to

Keyboard shortcuts

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