Documentation
¶
Index ¶
- Constants
- Variables
- func CommandAdd(conf Config, ctx, query Query) error
- func CommandContext(conf Config, state State, ctx, query Query) error
- func CommandDone(conf Config, ctx, query Query) error
- func CommandEdit(conf Config, ctx, query Query) error
- func CommandHelp(args []string)
- func CommandLog(conf Config, ctx, query Query) error
- func CommandModify(conf Config, ctx, query Query) error
- func CommandNext(conf Config, ctx, query Query) error
- func CommandNote(conf Config, ctx, query Query) error
- func CommandOpen(conf Config, ctx, query Query) error
- func CommandRemove(conf Config, ctx, query Query) error
- func CommandShowActive(conf Config, ctx, query Query) error
- func CommandShowOpen(conf Config, ctx, query Query) error
- func CommandShowPaused(conf Config, ctx, query Query) error
- func CommandShowProjects(conf Config, ctx, query Query) error
- func CommandShowResolved(conf Config, ctx, query Query) error
- func CommandShowTags(conf Config, ctx, query Query) error
- func CommandShowTemplates(conf Config, ctx, query Query) error
- func CommandShowUnorganised(conf Config, ctx, query Query) error
- func CommandStart(conf Config, ctx, query Query) error
- func CommandStop(conf Config, ctx, query Query) error
- func CommandSync(repoPath string) error
- func CommandTemplate(conf Config, ctx, query Query) error
- func CommandUndo(conf Config, args []string, ctx, query Query) error
- func CommandVersion()
- func ConfirmOrAbort(format string, a ...interface{})
- func DeduplicateStrings(s []string) []string
- func EnsureRepoExists(repoPath string)
- func ExitFail(format string, a ...interface{})
- func FixStr(text string, width int) string
- func GitCommit(repoPath, format string, a ...interface{}) error
- func Help(cmd string)
- func IntSliceContains(haystack []int, needle int) bool
- func IsValidPriority(priority string) bool
- func IsValidStateTransition(from string, to string) bool
- func IsValidStatus(status string) bool
- func IsValidUUID4String(str string) bool
- func MakeTempFilename(id int, summary, ext string) string
- func MustEditBytes(data []byte, tmpFilename string) []byte
- func MustGetRepoPath(repoPath, directory, file string) string
- func MustGetTermSize() (int, int)
- func MustGetUUID4String() string
- func MustGitCommit(repoPath, format string, a ...interface{})
- func MustOpenBrowser(url string)
- func MustRunGitCmd(repoPath string, args ...string)
- func RunCmd(name string, args ...string) error
- func RunGitCmd(repoPath string, args ...string) error
- func StdoutIsTTY() bool
- func StrSliceContains(haystack []string, needle string) bool
- func StrSliceContainsAll(subset, superset []string) bool
- func SumInts(vals ...int) int
- func Sync(repoPath string)
- func WriteStdout(data []byte) error
- type Config
- type IdsMap
- type Project
- type Query
- type RowStyle
- type SortByDirection
- type State
- type SubTask
- type Table
- type Task
- func (task *Task) Display()
- func (t Task) Equals(t2 Task) bool
- func (t *Task) LongSummary() string
- func (t *Task) MatchesFilter(query Query) bool
- func (t *Task) Modify(query Query)
- func (t *Task) Normalise()
- func (t *Task) SaveToDisk(repoPath string)
- func (t Task) String() string
- func (t *Task) Style() RowStyle
- func (t *Task) Validate() error
- type TaskSet
- func (ts *TaskSet) AllTasks() []Task
- func (ts *TaskSet) DisplayByNext(ctx Query, truncate bool) error
- func (ts TaskSet) DisplayByWeek()
- func (ts TaskSet) DisplayProjects() error
- func (ts *TaskSet) Filter(query Query)
- func (ts *TaskSet) FilterByStatus(status string)
- func (ts *TaskSet) FilterOrganised()
- func (ts *TaskSet) GetByID(id int) (Task, error)
- func (ts *TaskSet) GetProjects() []*Project
- func (ts *TaskSet) GetTags() map[string]bool
- func (ts *TaskSet) LoadTask(task Task) (Task, error)
- func (ts *TaskSet) MustGetByID(id int) Task
- func (ts *TaskSet) MustLoadTask(task Task) Task
- func (ts *TaskSet) MustUpdateTask(task Task)
- func (ts *TaskSet) NumTotal() int
- func (ts *TaskSet) SavePendingChanges()
- func (ts *TaskSet) SortByCreated(dir SortByDirection)
- func (ts *TaskSet) SortByPriority(dir SortByDirection)
- func (ts *TaskSet) SortByResolved(dir SortByDirection)
- func (ts *TaskSet) Tasks() []Task
- func (ts *TaskSet) UnHide()
- func (ts *TaskSet) UpdateTask(task Task) error
Constants ¶
const ( STATUS_PENDING = "pending" STATUS_ACTIVE = "active" STATUS_RESOLVED = "resolved" STATUS_DELEGATED = "delegated" STATUS_DEFERRED = "deferred" STATUS_PAUSED = "paused" STATUS_RECURRING = "recurring" STATUS_TEMPLATE = "template" CMD_NEXT = "next" CMD_ADD = "add" CMD_RM = "rm" CMD_REMOVE = "remove" CMD_TEMPLATE = "template" CMD_LOG = "log" CMD_START = "start" CMD_NOTE = "note" CMD_NOTES = "notes" CMD_STOP = "stop" CMD_DONE = "done" CMD_RESOLVE = "resolve" CMD_CONTEXT = "context" CMD_MODIFY = "modify" CMD_EDIT = "edit" CMD_UNDO = "undo" CMD_SYNC = "sync" CMD_OPEN = "open" CMD_GIT = "git" CMD_SHOW_NEXT = "show-next" CMD_SHOW_PROJECTS = "show-projects" CMD_SHOW_TAGS = "show-tags" CMD_SHOW_ACTIVE = "show-active" CMD_SHOW_PAUSED = "show-paused" CMD_SHOW_OPEN = "show-open" CMD_SHOW_RESOLVED = "show-resolved" CMD_SHOW_TEMPLATES = "show-templates" CMD_SHOW_UNORGANISED = "show-unorganised" CMD_COMPLETIONS = "_completions" CMD_HELP = "help" CMD_VERSION = "version" //nolint CMD_PRINT_ZSH_COMPLETION = "zsh-completion" //nolint CMD_PRINT_BASH_COMPLETION = "bash-completion" //nolint CMD_PRINT_FISH_COMPLETION = "fish-completion" // filter: P1 P2 etc PRIORITY_CRITICAL = "P0" PRIORITY_HIGH = "P1" PRIORITY_NORMAL = "P2" PRIORITY_LOW = "P3" MAX_TASKS_OPEN = 10000 TASK_FILENAME_LEN = 40 // if the terminal is too short, show this many tasks anyway MIN_TASKS_SHOWN = 8 // reserve this many lines for status messages/prompt TERMINAL_HEIGHT_MARGIN = 9 IGNORE_CONTEXT_KEYWORD = "--" NOTE_MODE_KEYWORD = "/" // theme loosely based on https://github.com/GothenburgBitFactory/taskwarrior/blob/2.6.0/doc/rc/dark-256.theme TABLE_MAX_WIDTH = 160 // keep it readable TABLE_COL_GAP = 2 // differentiate columns MODE_HEADER = 4 FG_DEFAULT = 250 BG_DEFAULT_1 = 233 BG_DEFAULT_2 = 232 MODE_DEFAULT = 0 FG_ACTIVE = 233 BG_ACTIVE = 250 BG_PAUSED = 236 // task that has been started then stopped FG_PRIORITY_CRITICAL = 160 FG_PRIORITY_HIGH = 166 FG_PRIORITY_NORMAL = FG_DEFAULT FG_PRIORITY_LOW = 245 FG_NOTE = 240 )
Variables ¶
var ( // for CI testing FAKE_PTY = false // populated by linker flags, see do-release.sh GIT_COMMIT = "Unknown" VERSION = "Unknown" BUILD_DATE = "Unknown" )
var ALL_CMDS = []string{ CMD_NEXT, CMD_ADD, CMD_RM, CMD_REMOVE, CMD_TEMPLATE, CMD_LOG, CMD_START, CMD_NOTE, CMD_NOTES, CMD_STOP, CMD_DONE, CMD_RESOLVE, CMD_CONTEXT, CMD_MODIFY, CMD_EDIT, CMD_UNDO, CMD_SYNC, CMD_OPEN, CMD_GIT, CMD_SHOW_NEXT, CMD_SHOW_PROJECTS, CMD_SHOW_TAGS, CMD_SHOW_ACTIVE, CMD_SHOW_PAUSED, CMD_SHOW_OPEN, CMD_SHOW_RESOLVED, CMD_SHOW_TEMPLATES, CMD_SHOW_UNORGANISED, CMD_COMPLETIONS, CMD_PRINT_BASH_COMPLETION, CMD_PRINT_FISH_COMPLETION, CMD_PRINT_ZSH_COMPLETION, CMD_HELP, CMD_VERSION, }
var ALL_STATUSES = []string{ STATUS_ACTIVE, STATUS_PENDING, STATUS_DELEGATED, STATUS_DEFERRED, STATUS_PAUSED, STATUS_RECURRING, STATUS_RESOLVED, STATUS_TEMPLATE, }
for import (etc) it's necessary to have full context
var HIDDEN_STATUSES = []string{ STATUS_RECURRING, STATUS_RESOLVED, STATUS_TEMPLATE, }
statuses which are hidden by default (direct addressing or show- commands needed to see them)
var NON_RESOLVED_STATUSES = []string{ STATUS_ACTIVE, STATUS_PENDING, STATUS_DELEGATED, STATUS_DEFERRED, STATUS_PAUSED, STATUS_RECURRING, STATUS_TEMPLATE, }
for most operations, it's not necessary or desirable to load the expensive resolved tasks
var VALID_STATUS_TRANSITIONS = [][]string{ {STATUS_PENDING, STATUS_ACTIVE}, {STATUS_ACTIVE, STATUS_PAUSED}, {STATUS_PAUSED, STATUS_ACTIVE}, {STATUS_PENDING, STATUS_RESOLVED}, {STATUS_PAUSED, STATUS_RESOLVED}, {STATUS_ACTIVE, STATUS_RESOLVED}, {STATUS_PENDING, STATUS_TEMPLATE}, }
incomplete until all statuses are implemented
Functions ¶
func CommandAdd ¶
CommandAdd adds a new task to the task database.
func CommandContext ¶
CommandContext sets a global context for dstask.
func CommandDone ¶
CommandDone marks a task as done.
func CommandEdit ¶
CommandEdit edits a task's metadata, such as status, projects, tags, etc.
func CommandHelp ¶
func CommandHelp(args []string)
CommandHelp prints for a specific command or all commands.
func CommandLog ¶
CommandLog logs a completed task immediately. Useful for tracking tasks after they're already completed.
func CommandModify ¶
CommandModify applies a change to tasks specified by ID, or all tasks in current context
func CommandNext ¶
CommandNext prints the unresolved tasks associated with the current context. This is the default command.
func CommandNote ¶
CommandNote edits or prints the markdown note associated with the task.
func CommandOpen ¶
CommandOpen opens a task URL in the browser, if the task has a URL.
func CommandRemove ¶
CommandRemove removes a task by ID from the database.
func CommandShowActive ¶
CommandShowActive prints a list of active tasks.
func CommandShowOpen ¶
CommandShowOpen prints a list of open tasks without truncation
func CommandShowPaused ¶
CommandShowPaused prints a list of paused tasks.
func CommandShowProjects ¶
CommandShowProjects prints a list of projects associated with all tasks. Ignores context/query for valid output
func CommandShowResolved ¶
CommandShowResolved prints a list of resolved tasks.
func CommandShowTags ¶
CommandShowTags prints a list of all tags associated with non-resolved tasks.
func CommandShowTemplates ¶
CommandShowTemplates show a list of task templates.
func CommandShowUnorganised ¶
CommandShowUnorganised prints a list of tasks without tags or projects. no context / query valid
func CommandStart ¶
CommandStart marks an existing task as started, by ID. If no ID is specified, it creates a new task and starts it.
func CommandStop ¶
CommandStop marks a task as stopped.
func CommandSync ¶
CommandSync pushes and pulls task database changes from the remote repository.
func CommandTemplate ¶
CommandTemplate creates a new task template.
func CommandUndo ¶
CommandUndo performs undo with git revert.
func CommandVersion ¶
func CommandVersion()
CommandVersion prints version information for the dstask binary.
func ConfirmOrAbort ¶
func ConfirmOrAbort(format string, a ...interface{})
func DeduplicateStrings ¶
func EnsureRepoExists ¶
func EnsureRepoExists(repoPath string)
EnsureRepoExists checks for the existence of a dstask repository, or exits the program.
func GitCommit ¶ added in v0.26.0
GitCommit stages changes in the dstask repository and commits them.
func IntSliceContains ¶ added in v0.24.1
generics pls...
func IsValidPriority ¶
func IsValidStateTransition ¶
func IsValidStatus ¶
func IsValidUUID4String ¶
func MakeTempFilename ¶ added in v0.26.0
MakeTempFilename encodes the task ID and a truncated portion of a task summary into a string suitable for passing to ioutil.TempFile.
func MustEditBytes ¶
func MustGetRepoPath ¶
MustGetRepoPath returns the full path to a file within the dstask git repo. Pass file as an empty string to return the git repo directory itself.
func MustGetTermSize ¶
func MustGetUUID4String ¶
func MustGetUUID4String() string
func MustGitCommit ¶
func MustGitCommit(repoPath, format string, a ...interface{})
MustGitCommit is like GitCommit, except if any error is encountered, the program exits.
func MustOpenBrowser ¶
func MustOpenBrowser(url string)
func MustRunGitCmd ¶
MustRunGitCmd delegates to RunGitCmd and exits the program on any error.
func StdoutIsTTY ¶
func StdoutIsTTY() bool
func StrSliceContains ¶
func StrSliceContainsAll ¶
func Sync ¶
func Sync(repoPath string)
Sync performs a git pull, and then a git push. If any conflicts are encountered, the user will need to resolve them.
func WriteStdout ¶
Types ¶
type Config ¶
type Config struct { // Path to the git repository Repo string // Path to the dstask local state file. State will differ between machines StateFile string // Path to the ids file IDsFile string // An unparsed context string, provided via DSTASK_CONTEXT CtxFromEnvVar string }
Config models the dstask application's required configuration. All paths are absolute.
type IdsMap ¶
Persistent DB of UUID -> ID to ensure that tasks have a persistent ID local to this machine for their lifetime. This is important to ensure the correct task is targeted between operations. Historically, each task stored its preferred ID but this resulted in merge conflicts when 2 machines were using dstask concurrently on the same repository.
type Project ¶
type Project struct { Name string `json:"name"` Tasks int `json:"taskCount"` TasksResolved int `json:"resolvedCount"` // if any task is in the active state Active bool `json:"active"` // first task created Created time.Time `json:"created"` // last task resolved Resolved time.Time `json:"resolved"` // highest non-resolved priority within project Priority string `json:"priority"` }
type Query ¶ added in v0.24.1
type Query struct { Cmd string IDs []int Tags []string AntiTags []string Project string AntiProjects []string Priority string Template int Text string IgnoreContext bool // any words after the note operator: / Note string }
when referring to tasks by ID, NON_RESOLVED_STATUSES must be loaded exclusively -- even if the filter is set to show issues that have only some statuses.
func ParseQuery ¶ added in v0.24.1
ParseQuery parses the raw command line typed by the user.
func (Query) HasOperators ¶ added in v0.24.1
HasOperators returns true if the query has positive or negative projects/tags, priorities, template
func (*Query) Merge ¶ added in v0.24.1
Merge applies a context to a new task. Returns new Query, does not mutate.
func (Query) PrintContextDescription ¶ added in v0.24.1
func (query Query) PrintContextDescription()
type SortByDirection ¶
type SortByDirection string
const ( Ascending SortByDirection = "ascending" Descending SortByDirection = "descending" )
type State ¶
type State struct { // Context is an implicit command line that changes the behavior or display // of some commands. Context Query }
State models our local context for serialisation and deserialisation from our state file.
func LoadState ¶
LoadState reads the state file, if it exists. Otherwise a default State is returned.
func (*State) SetContext ¶
SetContext sets a context on State, with some validation.
type Table ¶
func (*Table) Render ¶
func (t *Table) Render()
render table, returning count of rows rendered gap of zero means fit terminal exactly by truncating table -- you will want a larger gap to account for prompt or other text. A gap of -1 means the row count is not limited -- useful for reports or inspecting tasks.
type Task ¶
type Task struct { // not stored in file -- rather filename and directory UUID string `json:"uuid" yaml:"-"` // TODO: use actual uuid.UUID type here Status string `json:"status" yaml:",omitempty"` // is new or has changed. Need to write to disk. WritePending bool `json:"-" yaml:"-"` // ephemeral, used to address tasks quickly. Non-resolved only. Populated // from IDCache or on-the-fly. ID int `json:"id" yaml:"-"` // Deleted, if true, marks this task for deletion Deleted bool `json:"-" yaml:"-"` // concise representation of task Summary string `json:"summary"` // more detail, or information to remember to complete the task Notes string `json:"notes"` Tags []string `json:"tags"` Project string `json:"project"` // see const.go for PRIORITY_ strings Priority string `json:"priority"` DelegatedTo string `json:"-"` Subtasks []SubTask `json:"-"` // uuids of tasks that this task depends on // blocked status can be derived. // TODO possible filter: :blocked. Also, :overdue Dependencies []string `json:"-"` Created time.Time `json:"created"` Resolved time.Time `json:"resolved"` Due time.Time `json:"due"` // contains filtered or unexported fields }
Task is our representation of tasks added at the command line and serialized to the task database on disk. It is rendered in multiple ways by the TaskSet to which it belongs.
func (Task) Equals ¶ added in v0.24.1
Equals returns whether t2 equals task. for equality, we only consider "core properties", we ignore WritePending, ID, Deleted and filtered
func (*Task) LongSummary ¶
provides Summary + Last note if available
func (*Task) MatchesFilter ¶
func (*Task) Normalise ¶
func (t *Task) Normalise()
Normalise mutates and sorts some of a task object's fields into a consistent format. This should make git diffs more useful.
func (*Task) SaveToDisk ¶
type TaskSet ¶
type TaskSet struct {
// contains filtered or unexported fields
}
func LoadTaskSet ¶ added in v0.24.1
LoadTaskSet constructs a TaskSet from a repo path..
func (*TaskSet) DisplayByNext ¶
DisplayByNext renders the TaskSet's array of tasks.
func (TaskSet) DisplayByWeek ¶
func (ts TaskSet) DisplayByWeek()
func (TaskSet) DisplayProjects ¶
func (*TaskSet) FilterByStatus ¶ added in v0.24.1
func (*TaskSet) FilterOrganised ¶ added in v0.24.1
func (ts *TaskSet) FilterOrganised()
func (*TaskSet) GetProjects ¶
func (*TaskSet) LoadTask ¶
LoadTask adds a task to the TaskSet, but only if it has a new uuid or no uuid. Return annotated task.
func (*TaskSet) MustGetByID ¶
func (*TaskSet) MustLoadTask ¶ added in v0.26.0
MustLoadTask is the same as LoadTask, except it exits on error.
func (*TaskSet) MustUpdateTask ¶
TODO maybe this is the place to check for invalid state transitions instead of the main switch statement. Though, a future 3rdparty sync system could need this to work regardless.
func (*TaskSet) SavePendingChanges ¶
func (ts *TaskSet) SavePendingChanges()
save pending changes to disk TODO return files that have been added/deleted/modified/renamed so they can be passed to git add for performance, instead of doing git add .
func (*TaskSet) SortByCreated ¶ added in v0.24.1
func (ts *TaskSet) SortByCreated(dir SortByDirection)
func (*TaskSet) SortByPriority ¶ added in v0.24.1
func (ts *TaskSet) SortByPriority(dir SortByDirection)
func (*TaskSet) SortByResolved ¶ added in v0.24.1
func (ts *TaskSet) SortByResolved(dir SortByDirection)
func (*TaskSet) UpdateTask ¶ added in v0.26.0
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
pkg
|
|
imp/tw
Package tw provides utilities for importing tasks from taskwarrior see https://taskwarrior.org/docs/design/task.html Filters can be used in taskwarrior to specify a subset.
|
Package tw provides utilities for importing tasks from taskwarrior see https://taskwarrior.org/docs/design/task.html Filters can be used in taskwarrior to specify a subset. |