Documentation ¶
Index ¶
- Constants
- Variables
- func GetTime(rawDate string, dateFormat string) (time.Time, error)
- func IsSliceContains(entry string, slice []string) bool
- func NewProgressWriter(updateFrequency time.Duration) progress.Writer
- func ParseColumnConfigs(key string, hiddenColumns []string) []table.ColumnConfig
- func Prompt(message string) string
- func Truncate(text string, length int) string
- type BasePrinterOpts
- type Printer
- type TableColumnConfig
- type TablePrinterOpts
Constants ¶
Variables ¶
var Columns = []string{ ColumnTask, ColumnSummary, ColumnProject, ColumnClient, ColumnStart, ColumnEnd, ColumnBillable, ColumnUnbillable, }
Columns lists all available columns that can be printed.
var HideableColumns = []string{ ColumnSummary, ColumnProject, ColumnClient, ColumnStart, ColumnEnd, }
HideableColumns lists all columns that can be hidden when printing.
Functions ¶
func GetTime ¶
GetTime parses a string based on the given format and returns the time. If the rawDate was an empty string, the today's midnight will return.
func IsSliceContains ¶
IsSliceContains checks if a string slice contains the given element or not.
func NewProgressWriter ¶
NewProgressWriter returns a pre-configured progress writer.
func ParseColumnConfigs ¶
func ParseColumnConfigs(key string, hiddenColumns []string) []table.ColumnConfig
ParseColumnConfigs parses the column configs taken from the config file. The hidden columns can be defined as flags and column config as well. During parsing, the flag based columns will take precedence.
Types ¶
type BasePrinterOpts ¶
type BasePrinterOpts struct { // Output is the location where `Print` prints. Output io.Writer // AutoIndex adds row number as the first column. AutoIndex bool // Title sets the printed data's title. // In case of tables, the title is the full-width first row. Title string // SortBy sets the list of columns that are used for sorting. // If a column name starts with `-` (hyphen), the direction is descending; // otherwise, the direction is treated as ascending. SortBy []string // HiddenColumns lists the columns that will be hidden during printing. HiddenColumns []string }
BasePrinterOpts represents the configuration for common printer options.
type Printer ¶
type Printer interface { // Print prints out the list of complete and incomplete entries. // The output location must be set through `BasePrinterOpts`. Print(completeEntries worklog.Entries, incompleteEntries worklog.Entries) error }
Printer represents a printer that can write worklog entries.
func NewTablePrinter ¶
func NewTablePrinter(opts *TablePrinterOpts) Printer
NewTablePrinter returns a new Printer that print tables to os.Stdout.
type TableColumnConfig ¶
type TableColumnConfig struct { Config table.ColumnConfig TruncateAt int }
TableColumnConfig represents the configuration of a column. The configuration is built up from two parts, `Config` which stands for the table column config and `TruncateAt` which defines the max length a column text; longer texts will be truncated.
type TablePrinterOpts ¶
type TablePrinterOpts struct { BasePrinterOpts Style table.Style ColumnConfig []table.ColumnConfig ColumnTruncates map[string]int }
TablePrinterOpts represents the configuration for a table base printer. Table based printer sends the output to os.Stdout and draws an ascii-based table.