commands

package
v0.0.0-...-c5339c6 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TaskLine = regexp.MustCompile("(?m)^\\[ \\] (.*)$")

TaskLine is the Perl regular expression `(?m)^\\[ \\] (.*)$` `(?m)` sets flags so that `^` `$` match line beginning endings.

Functions

func Add

func Add(out io.Writer, server AddTaskServer, args []string, filePath string) error

Add or `go-habits add` command allows habiters to add new tasks to their list of todos. When running this command the format expected is like follows: go-habits a {{ TaskTitle }} TODO allow `due:DATE` to be parse and set via api.SetDueDate(t)

func Complete

func Complete(out io.Writer, ts TasksServer, args []string) error

Complete or `go-habits complete` allows habiters to complete todos on their existing list. `complete` task in a interger number representing the position of the todo they would like to complete.

func FilterTask

func FilterTask(id string, tasks []api.Task) []api.Task

FilterTask will filter a array of tasks by id.

func GetTaskAtPosition

func GetTaskAtPosition(ts TasksServer, p int) (api.Task, error)

GetTaskAtPosition returns todo from task server at a given position or index

func List

func List(out io.Writer, server ListServer, args []string) error

List or `go-habits list` command allows habiters to see their list of todos currently needing to be completed.

func Login

func Login(in io.Reader, out io.Writer, as Authenticator, args []string)

Login or `go-habits login` allows habiters to logon to a habitica server and save their api id and token to a config file. The file must be previously created.

func ParseTaskFromArguments

func ParseTaskFromArguments(args []string) api.Task

ParseTaskFromArguments parses an api.Task from []string

func ParseTasksFromFile

func ParseTasksFromFile(filePath string) ([]api.Task, error)

ParseTasksFromFile will return an array of tasks that matches `TaskLine` in the file given, line by line.

func Remove

func Remove(in io.Reader, out io.Writer, args []string, server DeleteServer) error

Remove will remove tasks by order as given in arguments from a `DeleteServer`

func RemoveForced

func RemoveForced(in io.Reader, out io.Writer, args []string, server DeleteServer) error

RemoveForced will remove tasks without asking by order as given in arguments from a `DeleteServer`

func Status

func Status(out io.Writer, server StatusServer) error

Status or `go-habits status` allows habiters to check if the habitica server api is up and running.

func StatusMessage

func StatusMessage(resp api.Status) string

StatusMessage returns text based on Status message

Types

type AddTaskServer

type AddTaskServer interface {
	AddTask(api.Task) (api.Task, error)
	GetTasks(api.TaskType) []api.Task
}

AddTaskServer interface handles adding and getting tasks from a habits server

type Authenticator

type Authenticator interface {
	Authenticate(string, string) (api.UserToken, error)
}

Authenticator small interface for Authenticating users by password and username to return a Token

type DeleteServer

type DeleteServer interface {
	TasksServer
	DeleteTask(api.Task) error
}

DeleteServer interface does everything a `TaskServer` does and Deletes tasks.

type ListServer

type ListServer interface {
	GetTasks(api.TaskType) []api.Task
}

ListServer interface GetTasks will return []Task

type StatusServer

type StatusServer interface {
	GetServerStatus() (api.Status, error)
	GetHostURL() string
}

StatusServer is an interface for habitica server that has an Server status

type TasksServer

type TasksServer interface {
	GetTasks(api.TaskType) []api.Task
	AddTask(api.Task) (api.Task, error)
	ScoreTaskUp(api.Task) (api.ScoreUpDelta, error)
}

TasksServer interface is able to Get, Add, and Score Up tasks

Jump to

Keyboard shortcuts

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