jobsui

package module
v0.0.0-...-8284568 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: GPL-3.0 Imports: 4 Imported by: 0

README

go-jobs-ui

example screenshot

This is very simple TUI library for building ui with list of multiple completable tasks.

Each task can behave in a binary way (active/done) or can indicate progress 0-100% -> done

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	Name        string
	Description string
	Progress    int
	State       JobState
	// contains filtered or unexported fields
}

Job represents a simple job with name, description and status

func NewJob

func NewJob(name, description string, widget *tui.Label) *Job

NewJob creates new Job object with given name The name parameter is not visible and is used to search for given job The description parameter is what will be shown in the ui

func (*Job) SetProgress

func (job *Job) SetProgress(progress int)

SetProgress changes this job progress to given value. The progress value will be shown in the status text with % sign. for example [ 40% ]

func (*Job) SetProgressWithInfo

func (job *Job) SetProgressWithInfo(progress int, infoText string)

SetProgressWithInfo changes this job progress to given value. The progress value will be shown in the status text with % sign. for example [ 40% ]

func (*Job) SetState

func (job *Job) SetState(state JobState)

SetState changes this job state to given one. The job will change it's text color and state text

func (*Job) SetStateWithInfo

func (job *Job) SetStateWithInfo(state JobState, additionalText string)

SetStateWithInfo changes this job state to the given one. The job will change it's text color and state text. Also additional text will be appended to the job description after ':' sign

type JobState

type JobState int

JobState represents the job state enum type

const (
	// Idle default state on created jobs
	Idle JobState = iota
	// Active states that the job is currently running
	Active
	// Skipped job was never run and will not be
	Skipped
	// Done the job was run and finished without error
	Done
	// Error the job was run and finished with error
	Error
)

type UI

type UI struct {
	Jobs map[string]*Job

	JobsDone chan bool
	// contains filtered or unexported fields
}

UI is a base struct for the interface

func NewUI

func NewUI() *UI

NewUI creates new interface with empty jobs list The ui event loop is started immediately in a seperate gorotuine

func (*UI) AddJob

func (ui *UI) AddJob(name, description string)

AddJob adds job to the ui list with given name and description The name is used only internally for lookup operations The description is what will be visible in the ui

func (*UI) SetJobProgress

func (ui *UI) SetJobProgress(name string, progress int) error

SetJobProgress sets job to active state and set its progress to given value If value is >= 100 the job state will automatically change to Done

func (*UI) SetJobProgressWithInfo

func (ui *UI) SetJobProgressWithInfo(name string, progress int, infoText string) error

SetJobProgressWithInfo sets job to active state and set its progress to given value, with additional text appended to its description If value is >= 100 the job state will automatically change to Done

func (*UI) SetJobState

func (ui *UI) SetJobState(name string, state JobState) error

SetJobState sets job to given state

func (*UI) SetJobStateWithInfo

func (ui *UI) SetJobStateWithInfo(name string, state JobState, infoText string) error

SetJobStateWithInfo sets job to given state, with additonal info text appended to its description

func (*UI) SetStatus

func (ui *UI) SetStatus(statusText string)

SetStatus sets temporary status bra text

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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