console

package
v0.0.0-...-d280c18 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package console contains code to pretty-print different types to the console.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration returns a formatted time.Duration in the format of h:mm:ss.

func PrintEntryEdit

func PrintEntryEdit(update dinkur.UpdatedEntry)

PrintEntryEdit writes a formatted entry and highlights any edits made to it, by diffing the before and after entries, to STDOUT.

func PrintEntryLabel

func PrintEntryLabel(labelled LabelledEntry)

PrintEntryLabel writes a label string followed by a formatted entry to STDOUT.

func PrintEntryLabelSlice

func PrintEntryLabelSlice(slice []LabelledEntry)

PrintEntryLabelSlice writes a table of label strings followed by a formatted entry to STDOUT.

func PrintEntryList

func PrintEntryList(entries []dinkur.Entry)

PrintEntryList writes a table for a list of entries, grouped by the date (year, month, day), to STDOUT.

func PrintEntryListSearched

func PrintEntryListSearched(entries []dinkur.Entry, searchStart, searchEnd string)

PrintEntryListSearched writes a table for a list of entries, grouped by the date (year, month, day), to STDOUT, as well as highlighting search terms (if any).

func PrintFatal

func PrintFatal(label string, v any)

PrintFatal writes a label and some error value to STDERR and then exits the application with status code 1.

func PromptDupEntryResolution

func PromptDupEntryResolution(activeEntry dinkur.Entry) (bool, error)

PromptDupEntryResolution asks the user for how to resolve creating a new duplicate entry.

func PromptEntryRemoval

func PromptEntryRemoval(entry dinkur.Entry) error

PromptEntryRemoval asks the user for confirmation about removing a entry. Will return an io.EOF error if the current TTY is not an interactive session.

func UsageTemplate

func UsageTemplate() string

UsageTemplate returns a lightly colored usage template for Cobra.

Types

type AFKResolution

type AFKResolution struct {
	Edit     *dinkur.EditEntry
	NewEntry *dinkur.NewEntry
}

AFKResolution states what should be changed as decided from the human's AFK resolution.

func PromptAFKResolution

func PromptAFKResolution(activeEntry dinkur.Entry, afkSince time.Time) (AFKResolution, error)

PromptAFKResolution asks the user for how to resolve an AFK status.

type LabelledEntry

type LabelledEntry struct {
	Label      string
	Entry      dinkur.Entry
	NoDuration bool
}

LabelledEntry holds a string label and a entry. Used when printing multiple labelled entries together.

Jump to

Keyboard shortcuts

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