cmd

package
v0.0.0-...-3a0190d Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREATETABLE = `` /* 173-byte string literal not displayed */

	INSERTGOAL    = `INSERT INTO goal (timestamp, goalmsg, achieved) VALUES (?, ?, ?)`
	GETGOALS      = `SELECT timestamp, goalmsg, achieved FROM goal`
	GETTODAYGOALS = "SELECT * FROM goal WHERE timestamp=?"
	DROPTABLE     = `DROP TABLE goal`
	UPDATEGOAL    = `UPDATE goal SET achieved=1 WHERE goalmsg=(?)`
)

Variables

View Source
var (
	GREEN = color.New(color.FgGreen)
	RED   = color.New(color.FgRed)
)
View Source
var DBFILE = UserHomeDir() + "/.gftd.db"

Functions

func AchieveCommand

func AchieveCommand() *cli.Command

func AchieveGoal

func AchieveGoal() error

func CreateDB

func CreateDB() error

Create a database file with a table.

func GetMotivationalQuote

func GetMotivationalQuote() (string, error)

GetMotivationalQuote will retrieve a random motivation quote.

func GetTableView

func GetTableView(goals []*Goal) *uitable.Table

Hacky tabular representation

func InitAction

func InitAction() error

func InitCommand

func InitCommand() *cli.Command

func IsDBExists

func IsDBExists() (bool, error)

Checks if the database exists or not.

func LogCommand

func LogCommand() *cli.Command

func NewCommand

func NewCommand() *cli.Command

func ReadGoal

func ReadGoal(r io.Reader) (string, error)

Reads a single-line goal from a reader.

func UpdateGoal

func UpdateGoal(msg string) error

func UserHomeDir

func UserHomeDir() string

func ViewGoals

func ViewGoals() error

func WriteGoal

func WriteGoal(goal *Goal) error

Writes a goal to the database

Types

type Goal

type Goal struct {
	Message   string
	Timestamp time.Time
	Achieved  bool
}

func PromptGoal

func PromptGoal() (*Goal, error)

func ReadAllGoals

func ReadAllGoals() ([]*Goal, error)

Reads all the goals currently in the database

func ReadTodayGoals

func ReadTodayGoals() ([]*Goal, error)

type Goals

type Goals []*Goal

type Pair

type Pair struct {
	Key   string
	Value int
}

type PairList

type PairList []Pair

func (PairList) Len

func (p PairList) Len() int

func (PairList) Less

func (p PairList) Less(i, j int) bool

func (PairList) Swap

func (p PairList) Swap(i, j int)

Jump to

Keyboard shortcuts

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