name -> message
This commit is contained in:
parent
95df3be0e9
commit
b4169c3d6f
6
main.go
6
main.go
|
@ -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,
|
||||
}
|
||||
|
|
8
store.go
8
store.go
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue