name -> message

This commit is contained in:
Kevin Schoon 2018-01-17 13:14:20 +08:00
parent 95df3be0e9
commit b4169c3d6f
3 changed files with 8 additions and 8 deletions

View File

@ -37,11 +37,11 @@ func startTask(task Task, prompter Prompter, db *Store) {
}
func start(cmd *cli.Cmd) {
cmd.Spec = "[OPTIONS] NAME"
cmd.Spec = "[OPTIONS] MESSAGE"
var (
duration = cmd.StringOpt("d duration", "25m", "duration of each stent")
count = cmd.IntOpt("c count", 4, "number of working stents")
name = cmd.StringArg("NAME", "", "descriptive name of the given task")
message = cmd.StringArg("MESSAGE", "", "descriptive name of the given task")
path = cmd.StringOpt("p path", defaultDBPath(), "path to the pomo state directory")
)
cmd.Action = func() {
@ -51,7 +51,7 @@ func start(cmd *cli.Cmd) {
maybe(err)
defer db.Close()
task := Task{
Name: *name,
Message: *message,
count: *count,
duration: parsed,
}

View File

@ -36,7 +36,7 @@ func (s Store) CreateTask(task Task) (int, error) {
if err != nil {
return -1, err
}
_, err = tx.Exec("INSERT INTO task (name) VALUES ($1)", task.Name)
_, err = tx.Exec("INSERT INTO task (message) VALUES ($1)", task.Message)
if err != nil {
tx.Rollback()
return -1, err
@ -60,14 +60,14 @@ func (s Store) CreateRecord(taskID int, record Record) error {
}
func (s Store) ReadTasks() ([]*Task, error) {
rows, err := s.db.Query(`SELECT rowid,name FROM task`)
rows, err := s.db.Query(`SELECT rowid,message FROM task`)
if err != nil {
return nil, err
}
tasks := []*Task{}
for rows.Next() {
task := &Task{Records: []*Record{}}
err = rows.Scan(&task.ID, &task.Name)
err = rows.Scan(&task.ID, &task.Message)
if err != nil {
return nil, err
}
@ -113,7 +113,7 @@ func (s Store) Close() error { return s.db.Close() }
func initDB(db *Store) error {
stmt := `
CREATE TABLE task (
name TEXT
message TEXT
);
CREATE TABLE record (
task_id INTEGER,

View File

@ -9,7 +9,7 @@ import (
// Task describes some activity
type Task struct {
ID int `json:"id"`
Name string `json:"name"`
Message string `json:"message"`
Records []*Record `json:"records"`
count int
duration time.Duration