-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✨ added -l persistant flag on tasks command * added -l flag to select task list. Usage: gtasks tasks -l "To watch" view|add|rm|done * defaults to selecting prompt when the flag is missing * also fixes the bug where incomplete tasks showed with -i flag * ♻️ refactor treewide, add logging * refactored codebase * added centralised, more configurable logging * 🎨 moved to better and colorful printing * utils package handles printing * needs testing for all commands * 📝 update root version * 📄 update README
- Loading branch information
Showing
12 changed files
with
284 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package api | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/BRO3886/gtasks/internal/utils" | ||
"google.golang.org/api/tasks/v1" | ||
) | ||
|
||
type TaskList []tasks.TaskList | ||
|
||
func (e TaskList) Len() int { | ||
return len(e) | ||
} | ||
|
||
func (e TaskList) Less(i, j int) bool { | ||
return e[i].Title < e[j].Title | ||
} | ||
|
||
func (e TaskList) Swap(i, j int) { | ||
e[i], e[j] = e[j], e[i] | ||
} | ||
|
||
func GetTaskLists(srv *tasks.Service) ([]tasks.TaskList, error) { | ||
r, err := srv.Tasklists.List().Do() | ||
if err != nil { | ||
utils.ErrorP("Unable to retrieve task lists. %v\n", err) | ||
} | ||
|
||
var list []tasks.TaskList | ||
|
||
if len(r.Items) == 0 { | ||
return nil, errors.New("no Tasklist found") | ||
} | ||
|
||
for _, item := range r.Items { | ||
list = append(list, *item) | ||
} | ||
|
||
return list, nil | ||
} | ||
|
||
func UpdateTaskList(srv *tasks.Service, tl *tasks.TaskList) (*tasks.TaskList, error) { | ||
r, err := srv.Tasklists.Patch(tl.Id, tl).Do() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return r, nil | ||
} | ||
|
||
func DeleteTaskList(srv *tasks.Service, tID string) error { | ||
err := srv.Tasklists.Delete(tID).Do() | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.