Documentation
¶
Index ¶
- Constants
- Variables
- func CheckWaitInterval(iTime time.Time, wait time.Duration) (time.Time, bool)
- func ClearScreen()
- func FmtHelp(src string, appName string, version string, releaseDate string, ...) string
- func JSONMarshal(data interface{}) ([]byte, error)
- func JSONMarshalIndent(data interface{}, prefix string, indent string) ([]byte, error)
- func JSONUnmarshal(src []byte, data interface{}) error
- 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
- func SetupScreen(out io.Writer)
- type Skimmer
- func (app *Skimmer) ChannelsToUrls(db *sql.DB) ([]byte, error)
- func (app *Skimmer) Download(db *sql.DB) error
- func (app *Skimmer) ItemCount(db *sql.DB) (int, error)
- func (app *Skimmer) MarkItem(db *sql.DB, link string, val string) error
- func (app *Skimmer) PruneItems(db *sql.DB, startDT time.Time, endDT time.Time) error
- func (app *Skimmer) ReadUrls(fName string) error
- func (app *Skimmer) RelabelItem(db *sql.DB, link string, label string) error
- func (app *Skimmer) ResetChannels(db *sql.DB) error
- func (app *Skimmer) Run(in io.Reader, out io.Writer, eout io.Writer, args []string) error
- func (app *Skimmer) RunInteractive(db *sql.DB) error
- func (app *Skimmer) Setup(fPath string) error
- func (app *Skimmer) TagItem(db *sql.DB, link string, tag string) error
- func (app *Skimmer) Write(db *sql.DB) error
Constants ¶
const ( // Version number of release Version = "0.0.4" // ReleaseDate, the date version.go was generated ReleaseDate = "2023-10-10" // ReleaseHash, the Git hash when version.go was generated ReleaseHash = "8a1f5ef" LicenseText = `` /* 1025-byte string literal not displayed */ )
Variables ¶
var ( // SQLCreateTables provides the statements that are use to create our tables // It has two percent s, first is feed list name, second is datetime scheme // was generated. SQLCreateTables = `` /* 612-byte string literal not displayed */ // SQLResetChannels clear the channels talbe SQLResetChannels = `DELETE FROM channels;` // Update the channels in the skimmer file SQLUpdateChannel = `` /* 221-byte string literal not displayed */ // Update a feed item in the items table SQLUpdateItem = `REPLACE INTO items ( link, title, description, updated, published, feedLabel) VALUES (?, ?, ?, ?, ?, ?);` // Return link and title for Urls formatted output SQLChannelsAsUrls = `SELECT link, title FROM channels ORDER BY link;` // SQLItemCount returns a list of items in the items table SQLItemCount = `-- Count the items in the feed_items table. SELECT COUNT(*) FROM items;` // SQLDisplayItems returns a list of items in decending chronological order. SQLDisplayItems = `` /* 233-byte string literal not displayed */ SQLMarkItem = `UPDATE items SET status = ? WHERE link = ?;` SQLRelabelItem = `UPDATE items SET feedlabel = ? WHERE link = ?;` SQLTagItem = `UPDATE items SET tags = ? WHERE link = ?;` // SQLPruneItems will prune our items table for all items that have easier // a updated or publication date early than the timestamp provided. SQLPruneItems = `` /* 145-byte string literal not displayed */ )
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 ClearScreen ¶ added in v0.0.3
func ClearScreen()
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 JSONMarshal ¶ added in v0.0.3
JSONMarshal provides provide a custom json encoder to solve a an issue with HTML entities getting converted to UTF-8 code points by json.Marshal(), json.MarshalIndent().
func JSONMarshalIndent ¶ added in v0.0.3
JSONMarshalIndent provides provide a custom json encoder to solve a an issue with HTML entities getting converted to UTF-8 code points by json.Marshal(), json.MarshalIndent().
func JSONUnmarshal ¶ added in v0.0.3
JSONUnmarshal is a custom JSON decoder so we can treat numbers easier
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)) } }
```
func SetupScreen ¶ added in v0.0.3
Types ¶
type Skimmer ¶
type Skimmer struct { // AppName holds the name of the application AppName string `json:"app_name,omitempty"` // DbName holds the path to the SQLite3 database DBName string `json:"db_name,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 bool `json:"prune,omitempty"` // Interactive if true causes Run to display one item at a time with a minimal of input Interactive bool `json:"interactive,omitempty"` // AsURLs, output the skimmer feeds as a newsboat style url file AsURLs bool `json:"urls,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) ChannelsToUrls ¶ added in v0.0.3
ChannelsToUrls converts the current channels table to Urls formated output and refreshes app.Urls data structure.
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 urls or OPML file provided and updates the feeds in the skimmer skimmer file.
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.
OPML is documented at http://opml.org
func (*Skimmer) RelabelItem ¶ added in v0.0.3
func (*Skimmer) Run ¶
Run provides the runner for skimmer. It allows for testing of much of the cli functionality
func (*Skimmer) RunInteractive ¶ added in v0.0.3
RunInteractive provides a sliver of interactive UI, basically displaying an item then prompting for an action.
func (*Skimmer) Setup ¶
Setup checks to see if anything needs to be setup (or fixed) for skimmer to run.