-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathwatson.ts
704 lines (701 loc) · 21.9 KB
/
watson.ts
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
// https://tailordev.github.io/Watson/
const listProjects: Fig.Generator = {
script: ["watson", "projects"],
postProcess: (output) => {
return output.split("\n").map((project) => ({
name: project,
icon: "🗂",
}));
},
};
const listTags: Fig.Generator = {
script: ["watson", "tags"],
postProcess: (output) => {
return output.split("\n").map((tag) => ({
name: tag,
icon: "🏷",
}));
},
};
const listFrames: Fig.Generator = {
script: ["watson", "log", "--json", "--reverse"],
postProcess: (output) => {
return JSON.parse(output).map((frame) => ({
name: frame.id.substring(0, 7),
icon: "⏲",
displayName: `${frame.id.substring(0, 7)} - ${frame.project} - ${
frame.start
}`,
}));
},
};
const completionSpec: Fig.Spec = {
name: "watson",
description: "A wonderful CLI to track your time",
subcommands: [
{
name: "add",
description:
"Add time to a project with tag(s) that was not tracked live",
args: {
generators: [listProjects, listTags],
},
options: [
{
name: ["--from", "-f"],
description: "Date and time of start of tracked activity",
args: {
name: "DATETIME",
description: "The start time. Ex: 2022-03-04 12:00:00",
},
},
{
name: ["--to", "-t"],
description: "Date and time of end of tracked activity",
args: {
name: "DATETIME",
description: "The start time. Ex: 2022-03-04 12:00:00",
},
},
{
name: ["--confirm-new-project", "-c"],
description: "Confirm creation of new tag",
},
],
},
{
name: "aggregate",
description:
"Display a report of the time spent on each project aggregated by day",
options: [
{
name: ["--current", "-c"],
description: "Include currently running frame in report",
exclusiveOn: ["-C"],
},
{
name: ["--no-current", "-C"],
description: "Don't include currently running frame in report",
exclusiveOn: ["--current"],
},
{
name: ["--from", "-f"],
description:
"The date from when the reports should start. Defaults to seven days ago",
args: {
name: "DATETIME",
description: "The start time. Ex: 2022-03-04 12:00:00",
},
},
{
name: ["--to", "-t"],
description:
"The date at which the report should stop (inclusive). Defaults to tomorrow",
args: {
name: "DATETIME",
description: "The start time. Ex: 2022-03-04 12:00:00",
},
},
{
name: ["--project", "-p"],
description:
"Reports activity only for the given project. You can add other projects by using this option several times",
args: {
generators: listProjects,
name: "PROJECT",
},
},
{
name: ["--tag", "-T"],
description:
"Reports activity only for frames containing the given tag. You can add several tags by using this option multiple times",
args: {
generators: listTags,
name: "TAG",
},
},
{
name: ["--json", "-j"],
description: "Format output in JSON instead of plain text",
exclusiveOn: ["--csv", "--pager", "--no-pager"],
},
{
name: ["--csv", "-s"],
description: "Format output in CSV instead of plain text",
exclusiveOn: ["--json", "--pager", "--no-pager"],
},
{
name: ["--pager", "-g"],
description: "View output through a pager",
exclusiveOn: ["--csv", "--json", "--no-pager"],
},
{
name: ["--no-pager", "-G"],
description: "Don't view output through a pager",
exclusiveOn: ["--csv", "--pager", "--json"],
},
],
},
{
name: "cancel",
description:
"Cancel the last call to the start command. The time will not be recorded",
},
{
name: "config",
description: "Get and set configuration options",
options: [
{
name: ["--edit", "-e"],
description: "Edit the configuration file with an editor",
},
],
args: [
{
name: "SECTION.OPTION",
suggestions: [
{
name: "backend.url",
description:
"This is the API root url of your repository, e.g. https://my.server.com/api/",
},
{
name: "backend.token",
description:
"To authenticate watson as an API client, once generated, you will need to set up your API token in your configuration, e.g. 7e329263e329",
},
{
name: "options.confirm_new_project",
description:
"If true, the user will be asked for confirmation before creating a new project. The option can be overriden in the command line with --confirm-new-project flag. Default: false",
},
{
name: "options.confirm_new_tag",
description:
"If true, the user will be asked for confirmation before creating a new tag. The option can be overriden in the command line with --confirm-new-tag flag. Default: false",
},
{
name: "options.date_format",
description:
"Globally configure how dates should be formatted. All python’s strftime directives are supported. Default: %Y.%m.%d",
},
{
name: "options.log_current",
description:
"If true, the output of the log command will include the currently running frame (if any) by default. The option can be overridden on the command line with the -c/-C resp. --current/--no-current flags. Default: false",
},
{
name: "options.pager",
description:
"If true, the output of the log and report command will be run through a pager by default. The option can be overridden on the command line with the -g/-G or --pager/--no-pager flags. If other commands output in colour, but log or report do not, try disabling the pager. Default: true",
},
{
name: "options.report_current",
description:
"If true, the output of the report command will include the currently running frame (if any) by default. The option can be overridden on the command line with the -c/-C resp. --current/--no-current flags. Default: false",
},
{
name: "options.reverse_log",
description:
"If true, the output of the log command will reverse the order of the days to display the latest day’s entries on top and the oldest day’s entries at the bottom. The option can be overridden on the command line with the -r/-R resp. --reverse/--no-reverse flags. Default: true",
},
{
name: "options.stop_on_start",
description:
"If true, starting a new project will stop running projects. Default false",
},
{
name: "options.stop_on_restart",
description:
"Similar to the options.stop_on_start option, but for the restart command. Default: false",
},
{
name: "options.time_format",
description:
"Globally configure how time should be formatted. All python’s strftime directives are supported. Default: %H.%M:%S%z",
},
{
name: "options.week_start",
description:
"Globally configure which day corresponds to the start of a week. Allowable values are monday, tuesday, wednesday, thursday, friday, saturday, and sunday",
},
],
},
{
name: "VALUE",
isOptional: true,
},
],
},
{
name: "edit",
description: "Edit a frame",
args: {
name: "FRAME ID",
generators: listFrames,
},
options: [
{
name: ["--confirm-new-project", "-c"],
description: "Confirm addition of new project",
},
{
name: ["--confirm-new-tag", "-b"],
description: "Confirm creation of new tag",
},
],
},
{
name: "frames",
description: "Display the list of all frame IDs",
},
{
name: "help",
description: "Display help information",
args: {
name: "COMMAND",
},
},
{
name: "log",
description: "Display each recorded session during the given timespan",
options: [
{
name: ["--current", "-c"],
description: "Include currently running frame in report",
exclusiveOn: ["--no-current"],
},
{
name: ["--no-current", "-C"],
description: "Don't include currently running frame in report",
exclusiveOn: ["--current"],
},
{
name: ["--reverse", "-r"],
description: "Reverse the order of the days in output",
exclusiveOn: ["--no-reverse"],
},
{
name: ["--no-reverse", "-R"],
description: "Don't Reverse the order of the days in output",
exclusiveOn: ["--reverse"],
},
{
name: ["--from", "-f"],
description:
"The date from when the log should start. Defaults to seven days ago",
args: {
name: "DATETIME",
},
},
{
name: ["--to", "-t"],
description:
"The date at which the log should stop (inclusive). Defaults to tomorrow",
args: {
name: "DATETIME",
},
},
{
name: ["--year", "-y"],
description: "Reports activity for the current year",
exclusiveOn: ["--month", "--luna", "--week", "--day", "--all"],
},
{
name: ["--month", "-m"],
description: "Reports activity for the current month",
exclusiveOn: ["--year", "--luna", "--week", "--day", "--all"],
},
{
name: ["--luna", "-l"],
description: "Reports activity for the current moon cycle",
exclusiveOn: ["--year", "--month", "--week", "--day", "--all"],
},
{
name: ["--week", "-w"],
description: "Reports activity for the current week",
exclusiveOn: ["--year", "--month", "--luna", "--day", "--all"],
},
{
name: ["--day", "-d"],
description: "Reports activity for the current day",
exclusiveOn: ["--year", "--month", "--luna", "--week", "--all"],
},
{
name: ["--all", "-a"],
description: "Reports all activities",
exclusiveOn: ["--year", "--month", "--luna", "--week", "--day"],
},
{
name: ["--project", "-p"],
description:
"Logs activity only for the given project. You can add other projects by using this option several times",
args: {
name: "PROJECT",
generators: listProjects,
isVariadic: true,
},
},
{
name: ["--tag", "-T"],
description:
"Logs activity only for frames containing the given tag. You can add several tags by using this option multiple times",
args: {
name: "TAG",
generators: listTags,
isVariadic: true,
},
},
{
name: "--ignore-project",
description:
"Logs activity for all projects but the given ones. You can ignore several projects by using the option multiple times. Any given project will be ignored",
args: {
name: "PROJECT",
generators: listProjects,
isVariadic: true,
},
},
{
name: "--ignore-tag",
description:
"Logs activity for all tags but the given ones. You can ignore several tags by using the option multiple times. Any given tag will be ignored",
args: {
name: "TAG",
generators: listTags,
isVariadic: true,
},
},
{
name: ["--json", "-j"],
description: "Format output in JSON instead of plain text",
exclusiveOn: ["--csv"],
},
{
name: ["--csv", "-s"],
description: "Format output in CSV instead of plain text",
exclusiveOn: ["--json"],
},
{
name: ["--pager", "-g"],
description: "View output through a pager",
exclusiveOn: ["--no-pager"],
},
{
name: ["--no-pager", "-G"],
description: "Don't view output through a pager",
exclusiveOn: ["--pager"],
},
],
},
{
name: "merge",
description:
"Perform a merge of the existing frames with a conflicting frames file. When storing the frames on a file hosting service, there is the possibility that the frame file goes out-of-sync due to one or more of the connected clients going offline. This can cause the frames to diverge",
args: {
name: "FRAMES_WITH_CONFLICT",
},
options: [
{
name: ["-f", "--force"],
description:
"If specified, then the merge will automatically be performed",
},
],
},
{
name: "projects",
description: "Display the list of all the existing projects",
},
{
name: "remove",
description:
"Remove a frame. You can specify the frame either by id or by position (ex: -1 for the last frame)",
args: {
name: "ID",
generators: listFrames,
},
options: [
{
name: ["-f", "--force"],
description: "Don’t ask for confirmation",
},
],
},
{
name: "rename",
description: "Rename a project or tag",
args: [
{
name: "type",
description: "Project or tag",
suggestions: [
{
name: "project",
icon: "🗂",
},
{
name: "tag",
icon: "🏷",
},
],
},
{
name: "OLD_NAME",
generators: [listProjects, listTags],
},
{
name: "NEW_NAME",
},
],
},
{
name: "report",
description: "Display a report of the time spent on each project",
options: [
{
name: ["--current", "-c"],
description: "Include currently running frame in report",
exclusiveOn: ["--no-current"],
},
{
name: ["--no-current", "-C"],
description: "Don't include currently running frame in report",
exclusiveOn: ["--current"],
},
{
name: ["--from", "-f"],
description:
"The date from when the report should start. Defaults to seven days ago",
args: {
name: "DATETIME",
},
},
{
name: ["--to", "-t"],
description:
"The date at which the report should stop (inclusive). Defaults to tomorrow",
args: {
name: "DATETIME",
},
},
{
name: ["--year", "-y"],
description: "Reports activity for the current year",
exclusiveOn: ["--month", "--luna", "--week", "--day", "--all"],
},
{
name: ["--month", "-m"],
description: "Reports activity for the current month",
exclusiveOn: ["--year", "--luna", "--week", "--day", "--all"],
},
{
name: ["--luna", "-l"],
description: "Reports activity for the current moon cycle",
exclusiveOn: ["--year", "--month", "--week", "--day", "--all"],
},
{
name: ["--week", "-w"],
description: "Reports activity for the current week",
exclusiveOn: ["--year", "--month", "--luna", "--day", "--all"],
},
{
name: ["--day", "-d"],
description: "Reports activity for the current day",
exclusiveOn: ["--year", "--month", "--luna", "--week", "--all"],
},
{
name: ["--project", "-p"],
description:
"Reports activity only for the given project. You can add other projects by using this option several times",
args: {
name: "PROJECT",
generators: listProjects,
},
},
{
name: ["--tag", "-T"],
description:
"Reports activity only for frames containing the given tag. You can add several tags by using this option multiple times",
args: {
name: "TAG",
generators: listTags,
},
},
{
name: "--ignore-project",
description:
"Reports activity for all projects but the given ones. You can ignore several projects by using the option multiple times. Any given project will be ignored",
args: {
name: "PROJECT",
generators: listProjects,
},
},
{
name: "--ignore-tag",
description:
"Reports activity for all tags but the given ones. You can ignore several tags by using the option multiple times. Any given tag will be ignored",
args: {
name: "TAG",
generators: listTags,
},
},
{
name: ["--json", "-j"],
description: "Format output in JSON instead of plain text",
exclusiveOn: ["--csv"],
},
{
name: ["--csv", "-s"],
description: "Format output in CSV instead of plain text",
exclusiveOn: ["--json"],
},
{
name: ["--pager", "-g"],
description: "View output through a pager",
exclusiveOn: ["--no-pager"],
},
{
name: ["--no-pager", "-G"],
exclusiveOn: ["--pager"],
description: "Don't view output through a pager",
},
],
},
{
name: "restart",
description: "Restart monitoring time for a previously stopped project",
args: {
name: "FRAME",
isOptional: true,
generators: listFrames,
},
options: [
{
name: "--at",
description:
"Start frame at this time. Must be in (YYYY-MM-DDT)?HH:MM(:SS)? format",
args: {
name: "DATETIME",
},
},
{
name: ["--stop", "-s"],
description: "Stop an already running project",
exclusiveOn: ["--no-stop"],
},
{
name: ["--no-stop", "-S"],
exclusiveOn: ["--stop"],
description: "Don't stop an already running project",
},
],
},
{
name: "start",
description:
"Start monitoring time for the given project. You can add tags indicating more specifically what you are working on with +tag",
args: {
name: "ARGS",
isVariadic: true,
generators: [listProjects, listTags],
},
options: [
{
name: "--at",
description:
"Start frame at this time. Must be in (YYYY-MM-DDT)?HH:MM(:SS)? format",
args: {
name: "DATETIME",
},
},
{
name: ["--gap", "-g"],
exclusiveOn: ["--no-gap"],
description:
"Leave gap between end time of previous project and start time of the current",
},
{
name: ["--no-gap", "-G"],
exclusiveOn: ["--gap"],
description:
"Don't leave gap between end time of previous project and start time of the current",
},
{
name: ["--confirm-new-project", "-c"],
description: "Confirm addition of new project",
},
{
name: ["--confirm-new-tag", "-b"],
description: "Confirm creation of new tag",
},
],
},
{
name: "status",
description:
"Display when the current project was started and the time spent since",
options: [
{
name: ["--project", "-p"],
description: "Only output project",
exclusiveOn: ["--tags", "--elapsed"],
},
{
name: ["--tags", "-t"],
description: "Only show tags",
exclusiveOn: ["--project", "--elapsed"],
},
{
name: ["--elapsed", "-e"],
description: "Only show time elapsed",
exclusiveOn: ["--project", "--tags"],
},
],
},
{
name: "stop",
description: "Stop monitoring time for the current project",
options: [
{
name: "--at",
description:
"Stop frame at this time. Must be in (YYYY-MM-DDT)?HH:MM(:SS)? format",
args: {
name: "DATETIME",
},
},
],
},
{
name: "sync",
description: "Get the frames from the server and push the new ones",
},
{
name: "tags",
description: "Display the list of all the tags",
},
],
options: [
{
name: "--help",
description: "Show help for watson",
isPersistent: true,
},
{
name: "--version",
description: "Show the version for watson",
},
{
name: "--color",
description: "Color output",
exclusiveOn: ["--no-color"],
},
{
name: "--no-color",
description: "No color output",
exclusiveOn: ["--color"],
},
],
};
export default completionSpec;