wtf

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DateFormat = "2006-01-02"

DateFormat defines the format we expect to receive dates from BambooHR in

View Source
const FriendlyDateTimeFormat = "Mon, Jan 2, 15:04"
View Source
const SimpleDateFormat = "Jan 2"
View Source
const SimpleTimeFormat = "15:04 MST"
View Source
const TimeFormat = "15:04"
View Source
const TimestampFormat = "2006-01-02T15:04:05-0700"

Variables

View Source
var Colors = map[string]tcell.Color{}/* 140 elements not displayed */
View Source
var Config *config.Config

Functions

func CenterText

func CenterText(str string, width int) string

func ColorFor

func ColorFor(label string) tcell.Color

func ConfigDir

func ConfigDir() (string, error)

func CreateConfigDir

func CreateConfigDir()

CreateConfigDir creates the .wtf directory in the user's home dir

func CreateFile

func CreateFile(fileName string) (string, error)

CreateFile creates the named file in the config directory, if it does not already exist. If the file exists it does not recreate it. If successful, eturns the absolute path to the file If unsuccessful, returns an error

func Exclude

func Exclude(strs []string, val string) bool

func ExecuteCommand

func ExecuteCommand(cmd *exec.Cmd) string

func ExpandHomeDir

func ExpandHomeDir(path string) (string, error)

Expand expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is.

func FindMatch added in v0.0.3

func FindMatch(pattern string, data string) [][]string

func Home

func Home() (string, error)

Dir returns the home directory for the executing user. An error is returned if a home directory cannot be detected.

func IsToday

func IsToday(date time.Time) bool

func LoadConfigFile

func LoadConfigFile(filePath string) *config.Config

LoadConfigFile loads the config.yml file to configure the app

func NameFromEmail

func NameFromEmail(email string) string

func NamesFromEmails

func NamesFromEmails(emails []string) []string

func NewBillboardModal

func NewBillboardModal(text string, closeFunc func()) *tview.Frame

func Now

func Now() time.Time

func OpenFile

func OpenFile(path string)

OpenFile opens the file defined in `path` via the operating system

func PadRow

func PadRow(offset int, max int) string

PadRow returns a padding for a row to make it the full width of the containing widget. Useful for ensurig row highlighting spans the full width (I suspect tcell has a better way to do this, but I haven't yet found it)

func PrettyDate

func PrettyDate(dateStr string) string

func ReadConfigFile

func ReadConfigFile(fileName string) (string, error)

func ReadFileBytes

func ReadFileBytes(filePath string) ([]byte, error)

func RightAlignFormat

func RightAlignFormat(view *tview.TextView) string

func RowColor

func RowColor(module string, idx int) string

func Schedule

func Schedule(widget Scheduler)

func SigilStr added in v0.0.4

func SigilStr(len, pos int, view *tview.TextView) string

func ToInts

func ToInts(slice []interface{}) []int

func ToStrs

func ToStrs(slice []interface{}) []string

func Tomorrow

func Tomorrow() time.Time

func UnixTime

func UnixTime(unix int64) time.Time

func WriteConfigFile

func WriteConfigFile()

WriteConfigFile creates a simple config file in the config directory if one does not already exist

Types

type CommandFlags added in v0.0.4

type CommandFlags struct {
	Config  string `short:"c" long:"config" optional:"yes" description:"Path to config file"`
	Module  string `short:"m" long:"module" optional:"yes" description:"Display info about a specific module, i.e.: 'wtf -m=todo'"`
	Version bool   `short:"v" long:"version" description:"Show Version Info"`
}

func NewCommandFlags added in v0.0.4

func NewCommandFlags() *CommandFlags

func (*CommandFlags) HasConfig added in v0.0.4

func (cmdFlags *CommandFlags) HasConfig() bool

func (*CommandFlags) HasModule added in v0.0.4

func (cmdFlags *CommandFlags) HasModule() bool

func (*CommandFlags) Parse added in v0.0.4

func (cmdFlags *CommandFlags) Parse(version string)

type Enabler

type Enabler interface {
	Disabled() bool
	Enabled() bool
}

type FocusState

type FocusState int
const (
	Widget FocusState = iota
	NonWidget
	NeverFocused
)

type FocusTracker

type FocusTracker struct {
	App     *tview.Application
	Idx     int
	Widgets []Wtfable
}

FocusTracker is used by the app to track which onscreen widget currently has focus, and to move focus between widgets.

func (*FocusTracker) Next

func (tracker *FocusTracker) Next()

Next sets the focus on the next widget in the widget list. If the current widget is the last widget, sets focus on the first widget.

func (*FocusTracker) None

func (tracker *FocusTracker) None()

None removes focus from the currently-focused widget.

func (*FocusTracker) Prev

func (tracker *FocusTracker) Prev()

Prev sets the focus on the previous widget in the widget list. If the current widget is the last widget, sets focus on the last widget.

func (*FocusTracker) Refocus

func (tracker *FocusTracker) Refocus()

type Position

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

func NewPosition added in v0.0.3

func NewPosition(top, left, width, height int) Position

func (*Position) Height

func (pos *Position) Height() int

func (*Position) Left

func (pos *Position) Left() int

func (*Position) Top

func (pos *Position) Top() int

func (*Position) Width

func (pos *Position) Width() int

type Scheduler

type Scheduler interface {
	Refresh()
	RefreshInterval() int
}

type TextWidget

type TextWidget struct {
	Name        string
	RefreshedAt time.Time
	RefreshInt  int
	View        *tview.TextView

	Position
	// contains filtered or unexported fields
}

func NewTextWidget

func NewTextWidget(name string, configKey string, focusable bool) TextWidget

func (*TextWidget) BorderColor

func (widget *TextWidget) BorderColor() string

func (*TextWidget) Disabled

func (widget *TextWidget) Disabled() bool

func (*TextWidget) Enabled

func (widget *TextWidget) Enabled() bool

func (*TextWidget) Focusable

func (widget *TextWidget) Focusable() bool

func (*TextWidget) RefreshInterval

func (widget *TextWidget) RefreshInterval() int

func (*TextWidget) TextView

func (widget *TextWidget) TextView() *tview.TextView

func (*TextWidget) UpdateRefreshedAt added in v0.0.3

func (widget *TextWidget) UpdateRefreshedAt()

type Wtfable

type Wtfable interface {
	Enabler
	Scheduler

	BorderColor() string
	Focusable() bool
	TextView() *tview.TextView

	Top() int
	Left() int
	Width() int
	Height() int
}

Jump to

Keyboard shortcuts

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