todos

package module
v0.0.0-...-be7bb3b Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: MIT Imports: 10 Imported by: 0

README

td Godoc

A to-do's CLI app written in Go. Inspired on The Power of the TODO List by James Hood (🐦 @jlhcoder).

Installation

$ go get -u github.com/gillchristian/todos/cmd/td

Usage

# Initialization

$ td init ~/Desktop/todos # initialize to-do's directory and create today's to-do file
$ td init                 # use default directory ~/.todos

# List TODOs and Acommplished items 

$ td list      # defaults to today's file (*)
$ td           # just an alias for ^
$ to list last # lists the last found (not today's)

# Add a TODO

$ td add <TODO item> # adds the item to today's list (*)

# Set a TODO as completed
# If I is not provided TD will list today's TODOs and ask for I

$ td done [I] # sets TODO #I as accomplised, if it exists (*)

# Remove a TODO
# If I is not provided TD will list today's TODOs and ask for I

$ td rm [I] # removes TODO #I, if it exists (*)

# Generate a report
# 

$ td report <week|month|year>
$ td report <week|month|year> -o <FILE> # write the report to <FILE>

(*) creates today's file if not yet created.

NOTE: if you use a custom directory you will have to specify it on every command with the --dir flag. A solution fo that is to use an alias:

alias td="td --dir ~/Desktop/todos"

TO-DO

  • $ td
  • $ td init
  • $ td list
  • $ td list last
  • $ td list <date>
  • $ td add <todo item>
  • $ td done [I]
  • $ td rm
  • $ td report <week|month|year>
  • Create today's file when not found (using yesterday's TODOs).
  • Feed back messages:
    • $ td init was not run, i.e. --dir does not exists.
    • No TODOs (well done! & suggest to use $ td add <todo item>).
    • No Accomplished (mmm! & suggest to use $ td done).
    • No items (both TODOs & Accomplished suggestions).
  • Add tests.

Documentation

Overview

Package todos handles creation of TODO files and adding and completting todos.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(dirPath string) (string, error)

Init initializes the TD's directory and creates a TodoFile at today's path.

Types

type TodoFile

type TodoFile struct {
	Todos    []string
	Accomps  []string
	Year     string
	Month    string
	Day      string
	Content  string
	BasePath string
}

TodoFile stores the data of a to-do file and has the relevant methods to interact with it.

func NewTodoFile

func NewTodoFile(path string) TodoFile

NewTodoFile creates a new TodoFile with path as the TD's base path.

func (*TodoFile) Accomplish

func (t *TodoFile) Accomplish(i int) error

Accomplish moves a TODO to the Accomplished list.

func (*TodoFile) Add

func (t *TodoFile) Add(text string) error

Add adds a TODO to the file.

func (TodoFile) Create

func (t TodoFile) Create() (string, error)

Create creates a todo file at "<t.BasePath>/<t.Year>/<t.Month>/<t.Day>". Asumes TD's base path has already been created.

func (*TodoFile) Dir

func (t *TodoFile) Dir() (string, error)

Dir returns the TodoFile directory path ("<base-path>/<year>/<month>"). If t.Year and/or t.Month are missing, they will first be assigend to the current year/month.

func (*TodoFile) FindPrev

func (t *TodoFile) FindPrev() (TodoFile, error)

FindPrev finds the previous TD file, perses and returns it.

func (*TodoFile) Path

func (t *TodoFile) Path() (string, error)

Path returns the TodoFile path ("<base-path>/<year>/<month>/<day>.txt"). If t.Year, t.Month and t.Day are missing, they will assigend first to the current date.

func (*TodoFile) Print

func (t *TodoFile) Print()

Print prints the TodoFile TODO & Accomplished lists.

func (*TodoFile) Read

func (t *TodoFile) Read() (int, error)

Read parses t to list todos and accomplished items. When parsing today's TodoFile it will create it if it does not exist.

func (*TodoFile) Write

func (t *TodoFile) Write() (int, error)

Write writes the lists into the file.

Directories

Path Synopsis
cmd
td

Jump to

Keyboard shortcuts

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