forked from naggie/dstask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
help.go
295 lines (231 loc) · 9.48 KB
/
help.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
package dstask
import (
"fmt"
"os"
)
func Help(cmd string) {
var helpStr string
showKey := false
switch cmd {
case CMD_NEXT:
helpStr = `Usage: dstask next [filter] [--]
Usage: dstask [filter] [--]
Example: dstask +work +bug --
Display list of non-resolved tasks in the current context, most recent last,
optional filter. It is the default command, so "next" is unnecessary.
Bypass the current context with --.
Colour key:
`
showKey = true
case CMD_ADD:
helpStr = `Usage: dstask add [template:<id>] [task summary] [--]
Example: dstask add Fix main web page 500 error +bug P1 project:website
Add a task, returning the git commit output which contains the task ID, used
later to reference the task.
Tags, project and priority can be added anywhere within the task summary.
Add -- to ignore the current context. / can be used when adding tasks to note
any words after.
A copy of an existing task can be made by including "template:<id>". See
"dstask help template" for more information on templates.
`
case CMD_TEMPLATE:
helpStr = `Usage dstask template <id> [task summary] [--]
Example: dstask template Fix main web page 500 error +bug P1 project:website
Example: dstask template 34 project:
If valid task ID is supplied, a copy of the task is created as a template. If
no ID is given, a new task template is created.
Tags, project and priority can be added anywhere within the task summary.
Add -- to ignore the current context. / can be used when adding tasks to note
any words after
Template tasks are not displayed with "show-open" or "show-next" commands.
Their intent is to act as a readily available task template for commonly used
or repeated tasks.
To create a new task from a template use the command:
"dstask add template:<id> [task summary] [--]"
The template task <id> remains unchanged, but a new task is created as a copy
with any modifications made in the task summary.
Github-style task lists (checklists) are recommended for templates, useful for
performing procedures. Example:
- [ ] buy bananas
- [ ] eat bananas
- [ ] make coffee
`
case CMD_RM, CMD_REMOVE:
helpStr = `Usage: dstask remove <id...>
Example: dstask 15 remove
Remove a task.
The task is deleted from the filesystem, and the change is committed.
`
case CMD_LOG:
helpStr = `Usage: dstask log [task summary] [--]
Example: dstask log Fix main web page 500 error +bug P1 project:website
Add an immediately resolved task. Syntax identical to add command.
Tags, project and priority can be added anywhere within the task summary.
Add -- to ignore the current context.
`
case CMD_START:
helpStr = `Usage: dstask <id...> start
Usage: dstask start [task summary] [--]
Example: dstask 15 start
Example: dstask start Fix main web page 500 error +bug P1 project:website
Mark a task as active, meaning you're currently at work on the task.
Alternatively, "start" can add a task and start it immediately with the same
syntax is the "add" command. Tags, project and priority can be added anywhere
within the task summary.
Add -- to ignore the current context.
`
case CMD_NOTE:
fallthrough
case CMD_NOTES:
helpStr = `Usage: dstask note <id>
Usage: dstask note <id> <text>
Example task 13 note problem is faulty hardware
Edit or append text to the markdown notes attached to a particular task.
`
case CMD_STOP:
helpStr = `Usage: dstask <id...> stop [text]
Example: dstask 15 stop
Example: dstask 15 stop replaced some hardware
Set a task as inactive, meaning you've stopped work on the task. Optional text
may be added, which will be appended to the note.
`
case CMD_RESOLVE:
fallthrough
case CMD_DONE:
helpStr = `Usage: dstask <id...> done [closing note]
Example: dstask 15 done
Example: dstask 15 done replaced some hardware
Resolve a task. Optional text may be added, which will be appended to the note.
`
case CMD_CONTEXT:
helpStr = `Usage: dstask context <filter>
Example: dstask context +work -bug
Example: dstask context none
Set a global filter consisting of a project, tags or antitags. Subsequent new
tasks and most commands will then have this filter applied automatically.
For example, if you were to run "task add fix the webserver," the given task
would then have the tag "work" applied automatically.
To reset to no context, run: dstask context none
Context can also be set with the environment variable DSTASK_CONTEXT. If set,
this context string will override the context stored on disk.
`
case CMD_MODIFY:
helpStr = `Usage: dstask <id...> modify <filter>
Usage: dstask modify <filter>
Example: dstask 34 modify -work +home project:workbench -project:website
Modify the attributes of the given tasks, specified by ID. If no ID is given,
the operation will be performed to all tasks in the current context subject to
confirmation.
Modifiable attributes: tags, project and priority.
`
case CMD_EDIT:
helpStr = `Usage: dstask <id...> edit
Edit a task in your text editor.
`
case CMD_UNDO:
helpStr = `Usage: dstask undo
Usage: dstask undo <n>
Undo the last <n> commits on the repository. Default is 1. Use
dstask git log
To see commit history. For more complicated history manipulation it may be best
to revert/rebase/merge on the dstask repository itself. The dstask repository
is at ~/.dstask by default.
`
case CMD_SYNC:
helpStr = `Usage: dstask sync
Synchronise with the remote git server. Runs git pull then git push. If there
are conflicts that cannot be automatically resolved, it is necessary to
manually resolve them in ~/.dstask or with the "task git" command.
`
case CMD_GIT:
helpStr = `Usage: dstask git <args...>
Example: dstask git status
Run the given git command inside ~/.dstask
`
case CMD_SHOW_RESOLVED:
helpStr = `Usage: dstask resolved
Show a report of last 1000 resolved tasks.
`
case CMD_SHOW_TEMPLATES:
helpStr = `Usage: dtask show-templates [filter] [--]
Show a report of stored template tasks with an optional filter.
Bypass the current context with --`
case CMD_OPEN:
helpStr = `Usage: dstask <id...> open
Open all URLs found within the task summary and notes. If you commonly have
dozens of tabs open to later action, convert them into tasks to open later with
this command.
`
case CMD_SHOW_PROJECTS:
helpStr = `Usage: dstask show-projects
Show a breakdown of projects with progress information
`
case CMD_PRINT_BASH_COMPLETION, CMD_PRINT_ZSH_COMPLETION, CMD_PRINT_FISH_COMPLETION:
helpStr = `Usage: dstask [bash|zsh|fish]-completion
Print a shell completion script to stdout. The script can be sourced from
a user's .bashrc, .zshrc, or fish.config like so:
source <(dstask bash-completion)
source <(dstask zsh-completion)
dtask fish-completion | source
`
default:
helpStr = `Usage: dstask [id...] <cmd> [task summary/filter]
Where [task summary] is text with tags/project/priority specified. Tags are
specified with + (or - for filtering) eg: +work. The project is specified with
a project:g prefix eg: project:dstask -- no quotes. Priorities run from P3
(low), P2 (default) to P1 (high) and P0 (critical). Text can also be specified
for a substring search of description and notes.
Cmd and IDs can be swapped, multiple IDs can be specified for batch
operations.
run "dstask help <cmd>" for command specific help.
Add -- to ignore the current context. / can be used when adding tasks to note
any words after.
Available commands:
next : Show most important tasks (priority, creation date -- truncated and default)
add : Add a task
template : Add a task template
log : Log a task (already resolved)
start : Change task status to active
note : Append to or edit note for a task
stop : Change task status to pending
done : Resolve a task
context : Set global context for task list and new tasks (use "none" to set no context)
modify : Change task attributes specified on command line
edit : Edit task with text editor
undo : Undo last n commits
sync : Pull then push to git repository, automatic merge commit.
open : Open all URLs found in summary/annotations
git : Pass a command to git in the repository. Used for push/pull.
remove : Remove a task (use to remove tasks added by mistake)
show-projects : List projects with completion status
show-tags : List tags in use
show-active : Show tasks that have been started
show-paused : Show tasks that have been started then stopped
show-open : Show all non-resolved tasks (without truncation)
show-resolved : Show resolved tasks
show-templates : Show task templates
show-unorganised : Show untagged tasks with no projects (global context)
bash-completion : Print bash completion script to stdout
fish-completion : Print fish completion script to stdout
zsh-completion : Print zsh completion script to stdout
help : Get help on any command or show this message
version : Show dstask version information
Colour Key:
`
showKey = true
}
fmt.Fprint(os.Stderr, helpStr)
if showKey {
colourPrintln(0, FG_PRIORITY_CRITICAL, BG_DEFAULT_2, "Critical priority")
colourPrintln(0, FG_PRIORITY_HIGH, BG_DEFAULT_2, "High priority")
colourPrintln(0, FG_DEFAULT, BG_DEFAULT_1, "Normal priority")
colourPrintln(0, FG_PRIORITY_LOW, BG_DEFAULT_2, "Low priority")
colourPrintln(0, FG_ACTIVE, BG_ACTIVE, "Active")
colourPrintln(0, FG_DEFAULT, BG_PAUSED, "Paused")
}
os.Exit(0)
}
func colourPrintln(mode, fg, bg int, line string) {
line = FixStr(line, 25)
fmt.Fprintf(os.Stderr, "\033[%d;38;5;%d;48;5;%dm%s\033[0m\n", mode, fg, bg, line)
}