@beauraines/rtm-cli 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/.github/FUNDING.yml +12 -0
  2. package/LICENSE +21 -0
  3. package/README.md +143 -0
  4. package/build.js +86 -0
  5. package/config.json +40 -0
  6. package/package.json +58 -0
  7. package/screens/ls.png +0 -0
  8. package/screens/lsd.png +0 -0
  9. package/screens/lsp.png +0 -0
  10. package/screens/planner.png +0 -0
  11. package/src/cli.js +434 -0
  12. package/src/cmd/add.js +100 -0
  13. package/src/cmd/addList.js +92 -0
  14. package/src/cmd/addTags.js +85 -0
  15. package/src/cmd/archiveList.js +78 -0
  16. package/src/cmd/comp.js +82 -0
  17. package/src/cmd/decPri.js +82 -0
  18. package/src/cmd/due.js +82 -0
  19. package/src/cmd/edit.js +82 -0
  20. package/src/cmd/incPri.js +82 -0
  21. package/src/cmd/lists.js +60 -0
  22. package/src/cmd/login.js +27 -0
  23. package/src/cmd/logout.js +31 -0
  24. package/src/cmd/ls.js +181 -0
  25. package/src/cmd/lsd.js +193 -0
  26. package/src/cmd/lsp.js +171 -0
  27. package/src/cmd/move.js +83 -0
  28. package/src/cmd/notes.js +150 -0
  29. package/src/cmd/planner.js +510 -0
  30. package/src/cmd/postpone.js +82 -0
  31. package/src/cmd/pri.js +82 -0
  32. package/src/cmd/remove.js +82 -0
  33. package/src/cmd/removeList.js +79 -0
  34. package/src/cmd/removeTags.js +85 -0
  35. package/src/cmd/renameList.js +80 -0
  36. package/src/cmd/reset.js +35 -0
  37. package/src/cmd/setUrl.js +99 -0
  38. package/src/cmd/tags.js +101 -0
  39. package/src/cmd/uncomp.js +82 -0
  40. package/src/cmd/url.js +92 -0
  41. package/src/cmd/whoami.js +36 -0
  42. package/src/interactive.js +65 -0
  43. package/src/utils/config.js +236 -0
  44. package/src/utils/filter.js +43 -0
  45. package/src/utils/finish.js +21 -0
  46. package/src/utils/index.js +10 -0
  47. package/src/utils/log.js +163 -0
  48. package/src/utils/login.js +69 -0
  49. package/src/utils/printIndicator.js +43 -0
  50. package/src/utils/prompt.js +126 -0
  51. package/src/utils/sort.js +283 -0
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ const log = require('../utils/log.js');
4
+ const config = require('../utils/config.js');
5
+ const { prompt } = require('../utils/prompt.js');
6
+
7
+ const finish = require('../utils/finish.js');
8
+
9
+
10
+ /**
11
+ * This command postpones the due date of 1 or more Tasks
12
+ * @param args indices...
13
+ * @param env
14
+ */
15
+ function action(args, env) {
16
+
17
+ // Prompt for tasks
18
+ if ( args.length === 0 ) {
19
+ prompt('Task:', _promptFinished);
20
+ }
21
+
22
+ // Process Tasks
23
+ else {
24
+ for ( let i = 0; i < args[0].length; i++ ) {
25
+ _process(args[0][i], i+1, args[0].length);
26
+ }
27
+ }
28
+
29
+ }
30
+
31
+
32
+ /**
33
+ * Process the returned answers
34
+ * @private
35
+ */
36
+ function _promptFinished(answers) {
37
+ for ( let i = 0; i < answers.length; i++ ) {
38
+ let answer = answers[i];
39
+ _process(answer[0], i+1, answers.length);
40
+ }
41
+ }
42
+
43
+
44
+ /**
45
+ * Process the request
46
+ * @private
47
+ */
48
+ function _process(task, count=1, max=1) {
49
+ log.spinner.start("Postponing Task(s)...");
50
+ config.user(function(user) {
51
+ task = parseInt(task.trim());
52
+
53
+ // Complete Task
54
+ user.tasks.postpone(task, function(err) {
55
+ if ( err ) {
56
+ log.spinner.error("Could not postpone Task #" + task + " (" + err.msg + ")");
57
+ }
58
+ _processFinished(count, max);
59
+ });
60
+
61
+ });
62
+ }
63
+
64
+ /**
65
+ * Request Callback
66
+ * @private
67
+ */
68
+ function _processFinished(count, max) {
69
+ log.spinner.start("Postponing Task [" + count + "/" + max + "]...");
70
+ if ( count === max ) {
71
+ log.spinner.success("Task(s) Postponed");
72
+ return finish();
73
+ }
74
+ }
75
+
76
+
77
+ module.exports = {
78
+ command: 'postpone [indices...]',
79
+ alias: 'pp',
80
+ description: 'Postpone one or more Tasks',
81
+ action: action
82
+ };
package/src/cmd/pri.js ADDED
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ const { prompt } = require('../utils/prompt.js');
4
+
5
+ const log = require('../utils/log.js');
6
+ const config = require('../utils/config.js');
7
+ const finish = require('../utils/finish.js');
8
+
9
+
10
+ /**
11
+ * This command updates the priority of 1 or more Tasks
12
+ * @param args index priority
13
+ * @param env
14
+ */
15
+ function action(args, env) {
16
+
17
+ // Process the given arguments
18
+ if ( args.length === 2 ) {
19
+ _process(args[0], args[1]);
20
+ }
21
+
22
+ // Prompt the User for the arguments
23
+ else {
24
+ prompt("Task:", "Priority:", _promptFinished);
25
+ }
26
+
27
+ }
28
+
29
+
30
+ /**
31
+ * Process the returned answers
32
+ * @private
33
+ */
34
+ function _promptFinished(answers) {
35
+ for ( let i = 0; i < answers.length; i++ ) {
36
+ let answer = answers[i];
37
+ _process(answer[0], answer[1], i+1, answers.length);
38
+ }
39
+ }
40
+
41
+
42
+ /**
43
+ * Process the request
44
+ * @private
45
+ */
46
+ function _process(index, priority, count=1, max=1) {
47
+ log.spinner.start("Setting Task Priority...");
48
+ config.user(function(user) {
49
+ index = parseInt(index.trim());
50
+ priority = parseInt(priority.trim());
51
+
52
+ // Update Priority
53
+ user.tasks.priority(index, priority, function(err) {
54
+ if ( err ) {
55
+ log.spinner.error("Could not update Task #" + index + " (" + err.msg + ")");
56
+ }
57
+ _processFinished(count, max);
58
+ });
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Request Callback
64
+ * @private
65
+ */
66
+ function _processFinished(count, max) {
67
+ log.spinner.start("Setting Task Priority [" + count + "/" + max + "]...");
68
+ if ( count === max ) {
69
+ log.spinner.success("Task(s) Updated");
70
+ return finish();
71
+ }
72
+ }
73
+
74
+
75
+
76
+
77
+ module.exports = {
78
+ command: 'pri [index] [priority]',
79
+ alias: 'p',
80
+ description: 'Change Task Priority',
81
+ action: action
82
+ };
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ const log = require('../utils/log.js');
4
+ const config = require('../utils/config.js');
5
+ const { prompt } = require('../utils/prompt.js');
6
+
7
+ const finish = require('../utils/finish.js');
8
+
9
+
10
+ /**
11
+ * This command remove 1 or more Tasks
12
+ * @param args indices...
13
+ * @param env
14
+ */
15
+ function action(args, env) {
16
+
17
+ // Prompt for tasks
18
+ if ( args.length === 0 ) {
19
+ prompt('Task:', _promptFinished);
20
+ }
21
+
22
+ // Process Tasks
23
+ else {
24
+ for ( let i = 0; i < args[0].length; i++ ) {
25
+ _process(args[0][i], i+1, args[0].length);
26
+ }
27
+ }
28
+
29
+ }
30
+
31
+
32
+ /**
33
+ * Process the returned answers
34
+ * @private
35
+ */
36
+ function _promptFinished(answers) {
37
+ for ( let i = 0; i < answers.length; i++ ) {
38
+ let answer = answers[i];
39
+ _process(answer[0], i+1, answers.length);
40
+ }
41
+ }
42
+
43
+
44
+ /**
45
+ * Process the request
46
+ * @private
47
+ */
48
+ function _process(task, count=1, max=1) {
49
+ log.spinner.start("Removing Task(s)...");
50
+ config.user(function(user) {
51
+ task = parseInt(task.trim());
52
+
53
+ // Complete Task
54
+ user.tasks.remove(task, function(err) {
55
+ if ( err ) {
56
+ log.spinner.error("Could not remove Task #" + task + " (" + err.msg + ")");
57
+ }
58
+ _processFinished(count, max);
59
+ });
60
+
61
+ });
62
+ }
63
+
64
+ /**
65
+ * Request Callback
66
+ * @private
67
+ */
68
+ function _processFinished(count, max) {
69
+ log.spinner.start("Removing Task [" + count + "/" + max + "]...");
70
+ if ( count === max ) {
71
+ log.spinner.success("Task(s) Removed");
72
+ return finish();
73
+ }
74
+ }
75
+
76
+
77
+ module.exports = {
78
+ command: 'remove [indices...]',
79
+ alias: 'rm',
80
+ description: 'Remove one or more Tasks',
81
+ action: action
82
+ };
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ const log = require('../utils/log.js');
4
+ const config = require('../utils/config.js');
5
+ const { prompt } = require('../utils/prompt.js');
6
+
7
+ const finish = require('../utils/finish.js');
8
+
9
+
10
+ /**
11
+ * This command removes 1 or more Lists from the User's account
12
+ * @param args name
13
+ * @param env
14
+ */
15
+ function action(args, env) {
16
+
17
+ // Prompt for Arguments
18
+ if ( args.length === 0 ) {
19
+ prompt('Remove List:', _promptFinished);
20
+ }
21
+
22
+ // Process the given arguments
23
+ else {
24
+ _process(args[0].join(' '));
25
+ }
26
+
27
+ }
28
+
29
+
30
+ /**
31
+ * Process the returned answers
32
+ * @private
33
+ */
34
+ function _promptFinished(answers) {
35
+ for ( let i = 0; i < answers.length; i++ ) {
36
+ let answer = answers[i];
37
+ _process(answer[0], i+1, answers.length);
38
+ }
39
+ }
40
+
41
+
42
+ /**
43
+ * Process the request
44
+ * @private
45
+ */
46
+ function _process(list, count=1, max=1) {
47
+ log.spinner.start("Removing List(s)...");
48
+ config.user(function(user) {
49
+ list = list.trim();
50
+
51
+ // Remove List
52
+ user.lists.remove(list, function(err) {
53
+ if ( err ) {
54
+ log.spinner.error("Could not Remove List " + list + " (" + err.msg + ")");
55
+ }
56
+ _processFinished(count, max);
57
+ });
58
+ });
59
+ }
60
+
61
+ /**
62
+ * Request Callback
63
+ * @private
64
+ */
65
+ function _processFinished(count, max) {
66
+ log.spinner.start("Removing List [" + count + "/" + max + "]...");
67
+ if ( count === max ) {
68
+ log.spinner.success("List(s) Removed");
69
+ return finish();
70
+ }
71
+ }
72
+
73
+
74
+ module.exports = {
75
+ command: 'removeList [name...]',
76
+ alias: 'rml',
77
+ description: 'Remove a List',
78
+ action: action
79
+ };
@@ -0,0 +1,85 @@
1
+ 'use strict';
2
+
3
+ const log = require('../utils/log.js');
4
+ const config = require('../utils/config.js');
5
+ const { prompt } = require('../utils/prompt.js');
6
+
7
+ const finish = require('../utils/finish.js');
8
+
9
+
10
+ /**
11
+ * This command removes 1 or more tags from a Task
12
+ * @param args index tags...
13
+ * @param env
14
+ */
15
+ function action(args, env) {
16
+
17
+ // Prompt for tags
18
+ if ( args.length < 2 ) {
19
+ prompt('Task:', 'Tags:', _promptFinished);
20
+ }
21
+
22
+ // Remove provided tags
23
+ else {
24
+ _process(args[0], args[1]);
25
+ }
26
+
27
+ }
28
+
29
+
30
+ /**
31
+ * Process the returned answers
32
+ * @private
33
+ */
34
+ function _promptFinished(answers) {
35
+ for ( let i = 0; i < answers.length; i++ ) {
36
+ let answer = answers[i];
37
+ _process(answer[0], answer[1], i+1, answers.length);
38
+ }
39
+ }
40
+
41
+
42
+ /**
43
+ * Process the request
44
+ * @private
45
+ */
46
+ function _process(task, tags, count=1, max=1) {
47
+ log.spinner.start("Removing Tags(s)...");
48
+ config.user(function(user) {
49
+
50
+ // Parse arguments
51
+ task = parseInt(task.trim());
52
+ if ( !Array.isArray(tags) ) {
53
+ tags = tags.trim().split(' ');
54
+ }
55
+
56
+ // Add Tags
57
+ user.tasks.removeTags(task, tags, function(err) {
58
+ if ( err ) {
59
+ log.spinner.error("Could not remove tags from Task #" + task + " (" + err.msg + ")");
60
+ }
61
+ _processFinished(count, max);
62
+ });
63
+
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Request Callback
69
+ * @private
70
+ */
71
+ function _processFinished(count, max) {
72
+ log.spinner.start("Removing Tags [" + count + "/" + max + "]...");
73
+ if ( count === max ) {
74
+ log.spinner.success("Tag(s) Removed");
75
+ return finish();
76
+ }
77
+ }
78
+
79
+
80
+ module.exports = {
81
+ command: 'removeTags [index] [tags...]',
82
+ alias: 'rmt',
83
+ description: 'Remove one or more tags from a Task',
84
+ action: action
85
+ };
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ const log = require('../utils/log.js');
4
+ const config = require('../utils/config.js');
5
+ const { prompt } = require('../utils/prompt.js');
6
+
7
+ const finish = require('../utils/finish.js');
8
+
9
+
10
+ /**
11
+ * This command renames 1 or more Lists
12
+ * @param args old new
13
+ * @param env
14
+ */
15
+ function action(args, env) {
16
+
17
+ // Prompt for Arguments
18
+ if ( args.length < 2 ) {
19
+ prompt('Old Name:', 'New Name:', _promptFinished);
20
+ }
21
+
22
+ // Process the given arguments
23
+ else {
24
+ _process(args[0], args[1]);
25
+ }
26
+
27
+ }
28
+
29
+
30
+ /**
31
+ * Process the returned answers
32
+ * @private
33
+ */
34
+ function _promptFinished(answers) {
35
+ for ( let i = 0; i < answers.length; i++ ) {
36
+ let answer = answers[i];
37
+ _process(answer[0], answer[1], i+1, answers.length);
38
+ }
39
+ }
40
+
41
+
42
+ /**
43
+ * Process the request
44
+ * @private
45
+ */
46
+ function _process(oldName, newName, count=1, max=1) {
47
+ log.spinner.start("Renaming List(s)...");
48
+ config.user(function(user) {
49
+ oldName = oldName.trim();
50
+ newName = newName.trim();
51
+
52
+ // Rename List
53
+ user.lists.rename(oldName, newName, function(err) {
54
+ if ( err ) {
55
+ log.spinner.error("Could not Rename List " + oldName + " (" + err.msg + ")");
56
+ }
57
+ _processFinished(count, max);
58
+ });
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Request Callback
64
+ * @private
65
+ */
66
+ function _processFinished(count, max) {
67
+ log.spinner.start("Renaming List [" + count + "/" + max + "]...");
68
+ if ( count === max ) {
69
+ log.spinner.success("List(s) Renamed");
70
+ return finish();
71
+ }
72
+ }
73
+
74
+
75
+ module.exports = {
76
+ command: 'renameList [oldName] [newName]',
77
+ alias: 'mvl',
78
+ description: 'Rename a List',
79
+ action: action
80
+ };
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ const log = require('../utils/log.js');
4
+ const config = require('../utils/config.js');
5
+ const parseFilter = require('../utils/filter.js');
6
+ const finish = require('../utils/finish.js');
7
+
8
+
9
+ /**
10
+ * This command removes any saved User information from the
11
+ * config files.
12
+ */
13
+ function action(args, env) {
14
+ config.user(function(user) {
15
+ log.spinner.start("Clearing Task Index Cache...");
16
+ user.clearTaskIndexCache();
17
+ log.spinner.start("Rebuilding Task Index Cache...");
18
+ user.tasks.get(parseFilter(), function(err) {
19
+ if ( err ) {
20
+ log.spinner.error("Could not rebuild Task Index Cache");
21
+ }
22
+ else {
23
+ log.spinner.success("Task Index Cache rebuilt");
24
+ }
25
+ return finish();
26
+ });
27
+ });
28
+ }
29
+
30
+
31
+ module.exports = {
32
+ command: 'reset',
33
+ description: 'Reset cached task indices',
34
+ action: action
35
+ };
@@ -0,0 +1,99 @@
1
+ 'use strict';
2
+
3
+ const log = require('../utils/log.js');
4
+ const config = require('../utils/config.js');
5
+ const { prompt } = require('../utils/prompt.js');
6
+
7
+ const finish = require('../utils/finish.js');
8
+
9
+
10
+ /**
11
+ * This command displays a task url
12
+ * @param args index
13
+ * @param env
14
+ */
15
+ function action(args, env) {
16
+
17
+ // Prompt for task
18
+ if ( args.length < 1 ) {
19
+ prompt('Task:', 'URL:', _promptFinished);
20
+ }
21
+
22
+ // Use provided args
23
+ else {
24
+ _process(args[0], args[1]);
25
+ }
26
+
27
+ }
28
+
29
+
30
+ /**
31
+ * Process the returned answers
32
+ * @private
33
+ */
34
+ function _promptFinished(answers) {
35
+ for ( let i = 0; i < answers.length; i++ ) {
36
+ let answer = answers[i];
37
+ _process(answer[0], answer[1],i+1, answers.length);
38
+ }
39
+ }
40
+
41
+
42
+ /**
43
+ * Process the request
44
+ * @private
45
+ */
46
+ function _process(index, url, count=1, max=1) {
47
+
48
+ // Make sure URL starts with http
49
+ if ( url === undefined || url === "" || url === " " ) {
50
+ url = "";
51
+ }
52
+ else if ( ! (url.startsWith("http://") || url.startsWith("https://")) ) {
53
+ url = "http://" + url;
54
+ }
55
+
56
+ // Display info
57
+ log.spinner.start("Updating Task(s)...");
58
+
59
+ // Get User
60
+ config.user(function(user) {
61
+
62
+ // Parse arguments
63
+ index = parseInt(index.trim());
64
+
65
+ // Set URL
66
+ user.tasks.setURL(index, url, function(err) {
67
+ if ( err ) {
68
+ log.spinner.error("Could not set URL for Task #" + index + " (" + err.msg + ")");
69
+ }
70
+ _processFinished(count, max);
71
+ });
72
+
73
+ });
74
+
75
+ }
76
+
77
+ /**
78
+ * Request Callback
79
+ * @private
80
+ */
81
+ function _processFinished(count, max) {
82
+ log.spinner.start("Updating Task [" + count + "/" + max + "]...");
83
+
84
+ // All tasks returned...
85
+ if ( count === max ) {
86
+ log.spinner.stop();
87
+ return finish();
88
+ }
89
+
90
+
91
+ }
92
+
93
+
94
+ module.exports = {
95
+ command: 'setUrl [index] [url]',
96
+ alias: 'su',
97
+ description: 'Set the URL of a Task',
98
+ action: action
99
+ };