Documentation ¶
Index ¶
- Constants
- func CheckWaitInterval(iTime time.Time, wait time.Duration) (time.Time, bool)
- func FmtHelp(src string, appName string, version string, releaseDate string, ...) string
- func ParseURLList(fName string, src []byte) (map[string]string, error)
- func ProgressETA(t0 time.Time, i int, tot int) string
- func ProgressIPS(t0 time.Time, i int, timeUnit time.Duration) string
- type Skimmer
- func (app *Skimmer) Download() error
- func (app *Skimmer) ItemCount() (int, error)
- func (app *Skimmer) PruneItems(dt time.Time) error
- func (app *Skimmer) ReadUrls() error
- func (app *Skimmer) Run(out io.Writer, eout io.Writer, args []string) error
- func (app *Skimmer) Setup(appDir string) error
- func (app *Skimmer) Write(out io.Writer) error
Constants ¶
const ( SkimmerURLs = "skimmer.urls" SkimmerScheme = "skimmer.scheme" SkimmerDB = "skimmer.db" )
const ( // Version number of release Version = "0.0.2" // ReleaseDate, the date version.go was generated ReleaseDate = "2023-10-06" // ReleaseHash, the Git hash when version.go was generated ReleaseHash = "68d0b7c" LicenseText = `` /* 1025-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func CheckWaitInterval ¶
CheckWaitInterval checks to see if an interval of time has been met or exceeded. It returns the remaining time interval (possibly reset) and a boolean. The boolean is true when the time interval has been met or exceeded, false otherwise.
``` tot := len(something) // calculate the total number of items to process t0 := time.Now() iTime := time.Now() reportProgress := false
for i, key := range records { // ... process stuff ... if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress { log.Printf("%s", ProgressETA(t0, i, tot)) } }
```
func FmtHelp ¶
func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string
FmtHelp lets you process a text block with simple curly brace markup.
func ParseURLList ¶
ParseURLList takes a filename and byte slice source, parses the contents returning a map of urls to labels and an error value.
func ProgressETA ¶
ProgressETA returns a string with the percentage processed and estimated time remaining. It requires the a counter of records processed, the total count of records and a time zero value.
``` tot := len(something) // calculate the total number of items to process t0 := time.Now() iTime := time.Now() reportProgress := false
for i, key := range records { // ... process stuff ... if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress { log.Printf("%s", ProgressETA(t0, i, tot)) } }
```
func ProgressIPS ¶
ProgressIPS returns a string with the elapsed time and increments per second. Takes a time zero, a counter and time unit. Returns a string with count, running time and increments per time unit. ``` t0 := time.Now() iTime := time.Now() reportProgress := false
for i, key := range records { // ... process stuff ... if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress || i = 0 { log.Printf("%s", ProgressIPS(t0, i, time.Second)) } }
```
Types ¶
type Skimmer ¶
type Skimmer struct { // AppName holds the name of the application AppName string `json:"app_name,omitempty"` // AppDir holds the path to the directory where the urls and feed_items.db are held AppDir string `json:"app_dir,omitempty"` // Fetch indicates that items need to be retrieved from the url list and stored in the database Fetch bool `json:"fetch,omitempty"` // Display indicates the contents of the database needs to be streamed to output Display bool `json:"read,omitempty"` // Urls are the map of urls to labels to be fetched or read Urls map[string]string `json:"urls,omitempty"` // Limit contrains the number of items shown Limit int `json:"limit,omitempty"` // Prune contains the date to use to prune the database. Prune string `json:"prune,omitempty"` // contains filtered or unexported fields }
Skimmer is the application structure that holds configuration and ties the app to the runner for the cli.
func (*Skimmer) PruneItems ¶
PruneItems takes a timestamp and performs a row delete on the table for items that are older than the timestamp.
func (*Skimmer) ReadUrls ¶
ReadUrls reads the $HOME/.skimmer/urls file and populates the app.Urls map. Newsboat's url file format is `<URL><SPACE>"~<LABEL>"` one entry per line The hash mark, "#" at the start of the line indicates a comment line.
func (*Skimmer) Run ¶
Run provides the runner for skimmer. It allows for testing of much of the cli functionality