todo

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package todo は "todo.txt" 形式のタスクを管理するためのパッケージです。

このパッケージは todotxt.TaskList 型(github.com/1set/todotxt)を拡張しています。

    QiiTask 独自のルール

    todo.txt の "(A)", "(B)" の優先度タグは、QiiTask では以下の意味を持ちます。

        (A) .... 部分ソート済み(主観的な質問でソートされたタスク、Subjective)
	    (B) .... 全体ソート済み(客観的な質問でソートされたタスク、Objective)
	    なし ... 未ソートのタスク

Index

Examples

Constants

View Source
const NameFile = "todo.txt"

NameFile はタスクのファイル名です。この定数値がファイルの読み込みに使われます。

Variables

View Source
var FilePathAbs = filepath.Abs

FilePathAbs は filepath.Abs のコピーです。テスト時に filepath.Abs の動作をモック する為に変数に代入しています。

View Source
var OsGetwd = os.Getwd

OsGetwd は os.Getwd のコピーです。テスト時に os.Getwd の動作をモックする為に変数 に代入しています。

View Source
var OsUserHomeDir = os.UserHomeDir

OsUserHomeDir は os.UserHomeDir のコピーです。テスト時に os.UserHomeDir の動作を モックする為に変数に代入しています。

Functions

This section is empty.

Types

type Set

type Set struct {
	Local  *Todo // Local: カレントディレクトリにあるタスク
	Global *Todo // Global: ユーザのホームディレクトリにあるタスク
}

Set はローカルおよびグローバルのタスクをセットで保持するための型です。

func NewSet

func NewSet(pathDirCurr, pathDirHome string) (*Set, error)

NewSet は新規 Set インスタンスを返します。Set はカレントディレクト リのタスク(Local タスク)およびユーザーのホームディレクトリ (Global タスク) を含みます。

引数はファイルの検索先のパスとして指定する必要があります。

Example
package main

import (
	"fmt"
	"log"

	"github.com/Qithub-BOT/QiiTask/core/todo"
)

func main() {
	// Path to search tasks
	pathToCurrentDir := "../../testdata/golden/working_with_task_and_conf/" // Usually "./"
	pathToUserHomeDir := "../../testdata/golden/user_home_with_task"        // Usually "~/"

	taskList, err := todo.NewSet(pathToCurrentDir, pathToUserHomeDir)
	if err != nil {
		log.Fatal(err)
	}

	// Get the first task from current dir (as local task).
	// Note that the 1st item is not "0" like the array key.
	taskLocal, err := taskList.Local.GetTask(1)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(taskLocal.Todo)

	// Get the first task from the user home dir (as global task).
	// Note that the 1st item is not "0" like the array key.
	taskGlobal, err := taskList.Global.GetTask(1)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(taskGlobal.Todo)

}
Output:
This is an un-done task in local (working dir) with conf in local.
This is an un-done task in global.

type Todo

type Todo struct {
	*todotxt.TaskList
	// contains filtered or unexported fields
}

Todo は todotxt.TaskList 型(github.com/1set/todotxt)を埋め込んだ拡張型です。

func New

func New(pathDir string) (*Todo, error)

New は Todo の新規オブジェクトを返します。pathDir のディレクトリ以下をサーチ し、最初に見つけた "todo.txt" をロードします。

通常、この関数を使ってタスクオブジェクトを生成することはなく、 NewList() 関 数を使ってローカルおよびグローバルにあるタスクがセットになったオブジェクトを 使います。

func (*Todo) CustomSort

func (t *Todo) CustomSort(isALessThanB func(a int, b int) bool)

CustomSort は isALessThanB を使ってタスクをソートします。

ソートは安定ソートです。また isALessThanB の関数は A が B より小さい場合に true を返す必要があります。

func (*Todo) Dir

func (t *Todo) Dir() string

Dir はタスクの読み込み・書き込みをする際に使われるディレクトリ名を返します。

func (*Todo) File

func (t *Todo) File() string

File はタスクの読み込み・書き込みをする際に使われるファイル名を返します。

func (*Todo) FileUsed

func (t *Todo) FileUsed() string

FileUsed は読み込んだタスク・ファイルのパスを返します。 ファイルが存在しない場合は "" にセットされています。

func (*Todo) GetTodoByKey

func (t *Todo) GetTodoByKey(key int) (string, error)

GetTodoByKey は t.TaskList[key] にある Todo フィールドの文字列値を返します。

GetTask と違いタスク ID ではなく、スライスのキー番号で指定します(ID は 1 ス タート、Key は 0 スタートです)。指定された key が範囲外の場合はエラーを返し ます。

func (*Todo) IsKeyDone

func (t *Todo) IsKeyDone(key int) bool

IsKeyDone は t.TaskList[key] にあるタスクが完了済み("x" 付き)の場合に true を返します。key が範囲外/存在しない場合は false を返します。

func (*Todo) Len

func (t *Todo) Len() int

Len は現在のタスクの長さ(len)を返します。 タスクもタスクのファイルも存在しない場合は -1 を返します。

func (*Todo) OverWrite

func (t *Todo) OverWrite(ui *cui.UI) error

OverWrite は現在状態のタスクを読み込み元のファイルに上書きします。 新規保存の場合は SaveAs を使います。

Jump to

Keyboard shortcuts

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