@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,78 @@
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 archives 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('Archive 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("Archiving List(s)...");
48
+ config.user(function(user) {
49
+ list = list.trim();
50
+ // Archive List
51
+ user.lists.archive(list, function(err) {
52
+ if ( err ) {
53
+ log.spinner.error("Could not Archive List " + list + " (" + err.msg + ")");
54
+ }
55
+ _processFinished(count, max);
56
+ });
57
+ });
58
+ }
59
+
60
+ /**
61
+ * Request Callback
62
+ * @private
63
+ */
64
+ function _processFinished(count, max) {
65
+ log.spinner.start("Archiving List [" + count + "/" + max + "]...");
66
+ if ( count === max ) {
67
+ log.spinner.success("List(s) Archived");
68
+ return finish();
69
+ }
70
+ }
71
+
72
+
73
+ module.exports = {
74
+ command: 'archiveList [name...]',
75
+ alias: 'arl',
76
+ description: 'Archive a List',
77
+ action: action
78
+ };
@@ -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 marks 1 or more Tasks as complete
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("Completing Task(s)...");
50
+ config.user(function(user) {
51
+ task = parseInt(task.trim());
52
+
53
+ // Complete Task
54
+ user.tasks.complete(task, function(err) {
55
+ if ( err ) {
56
+ log.spinner.error("Could not complete 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("Completing Task [" + count + "/" + max + "]...");
70
+ if ( count === max ) {
71
+ log.spinner.success("Task(s) Completed");
72
+ return finish();
73
+ }
74
+ }
75
+
76
+
77
+ module.exports = {
78
+ command: 'comp [indices...]',
79
+ alias: 'x',
80
+ description: 'Complete one or more Tasks',
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 decreases the priority 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("Prioritizing Task(s)...");
50
+ config.user(function(user) {
51
+ task = parseInt(task.trim());
52
+
53
+ // Decrease Priority
54
+ user.tasks.decreasePriority(task, function(err) {
55
+ if ( err ) {
56
+ log.spinner.error("Could not decrease priority of 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("Prioritizing Task [" + count + "/" + max + "]...");
70
+ if ( count === max ) {
71
+ log.spinner.success("Task(s) Prioritized");
72
+ return finish();
73
+ }
74
+ }
75
+
76
+
77
+ module.exports = {
78
+ command: 'decPri [indices...]',
79
+ alias: '-',
80
+ description: 'Decrease the Priority of one or more Tasks',
81
+ action: action
82
+ };
package/src/cmd/due.js ADDED
@@ -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 sets the due date for a Task
12
+ * @param args index due
13
+ * @param env
14
+ */
15
+ function action(args, env) {
16
+
17
+ // Prompt for due date
18
+ if ( args.length < 2 ) {
19
+ prompt('Task:', 'Due:', _promptFinished);
20
+ }
21
+
22
+ // Use provided args
23
+ else {
24
+ _process(args[0], args[1].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], answer[1], i+1, answers.length);
38
+ }
39
+ }
40
+
41
+
42
+ /**
43
+ * Process the request
44
+ * @private
45
+ */
46
+ function _process(task, due, count=1, max=1) {
47
+ log.spinner.start("Setting Due Date(s)...");
48
+ config.user(function(user) {
49
+
50
+ // Parse arguments
51
+ task = parseInt(task.trim());
52
+ due = due.trim();
53
+
54
+ // Set Due Date
55
+ user.tasks.setDueDate(task, due, function(err) {
56
+ if ( err ) {
57
+ log.spinner.error("Could not set due date for Task #" + task + " (" + err.msg + ")");
58
+ }
59
+ _processFinished(count, max);
60
+ });
61
+
62
+ });
63
+ }
64
+
65
+ /**
66
+ * Request Callback
67
+ * @private
68
+ */
69
+ function _processFinished(count, max) {
70
+ log.spinner.start("Setting Due Date [" + count + "/" + max + "]...");
71
+ if ( count === max ) {
72
+ log.spinner.success("Task(s) Updated");
73
+ return finish();
74
+ }
75
+ }
76
+
77
+
78
+ module.exports = {
79
+ command: 'due [index] [due...]',
80
+ description: 'Set the Due Date of a Task',
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 changes the name of a Task
12
+ * @param args index name
13
+ * @param env
14
+ */
15
+ function action(args, env) {
16
+
17
+ // Prompt for name
18
+ if ( args.length < 2 ) {
19
+ prompt('Task:', 'Name:', _promptFinished);
20
+ }
21
+
22
+ // Use provided args
23
+ else {
24
+ _process(args[0], args[1].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], answer[1], i+1, answers.length);
38
+ }
39
+ }
40
+
41
+
42
+ /**
43
+ * Process the request
44
+ * @private
45
+ */
46
+ function _process(task, name, count=1, max=1) {
47
+ log.spinner.start("Updating Task(s)...");
48
+ config.user(function(user) {
49
+
50
+ // Parse arguments
51
+ task = parseInt(task.trim());
52
+ name = name.trim();
53
+
54
+ // Set Name
55
+ user.tasks.setName(task, name, function(err) {
56
+ if ( err ) {
57
+ log.spinner.error("Could not change name for Task #" + task + " (" + err.msg + ")");
58
+ }
59
+ _processFinished(count, max);
60
+ });
61
+
62
+ });
63
+ }
64
+
65
+ /**
66
+ * Request Callback
67
+ * @private
68
+ */
69
+ function _processFinished(count, max) {
70
+ log.spinner.start("Updating Task [" + count + "/" + max + "]...");
71
+ if ( count === max ) {
72
+ log.spinner.success("Task(s) Updated");
73
+ return finish();
74
+ }
75
+ }
76
+
77
+
78
+ module.exports = {
79
+ command: 'edit [index] [name...]',
80
+ description: 'Change the name of a Task',
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 increases the priority 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("Prioritizing Task(s)...");
50
+ config.user(function(user) {
51
+ task = parseInt(task.trim());
52
+
53
+ // Increase Priority
54
+ user.tasks.increasePriority(task, function(err) {
55
+ if ( err ) {
56
+ log.spinner.error("Could not increase priority of 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("Prioritizing Task [" + count + "/" + max + "]...");
70
+ if ( count === max ) {
71
+ log.spinner.success("Task(s) Prioritized");
72
+ return finish();
73
+ }
74
+ }
75
+
76
+
77
+ module.exports = {
78
+ command: 'incPri [indices...]',
79
+ alias: '+',
80
+ description: 'Increase the Priority of one or more Tasks',
81
+ action: action
82
+ };
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ const log = require('../utils/log.js');
4
+ const finish = require('../utils/finish.js');
5
+ const config = require('../utils/config.js');
6
+ const styles = config.get().styles;
7
+
8
+
9
+ /**
10
+ * This command lists all of the User's RTM Lists
11
+ */
12
+ function action(args, env) {
13
+ config.user(function(user) {
14
+ log.spinner.start("Getting Lists...");
15
+
16
+ // Get Lists
17
+ user.lists.get(function(err, lists) {
18
+ if ( err ) {
19
+ log.spinner.error("Could not get lists (" + err.msg + ")");
20
+ return finish();
21
+ }
22
+ log.spinner.stop();
23
+
24
+ // Display List Information
25
+ for ( let i = 0; i < lists.length; i++ ) {
26
+ let list = lists[i];
27
+
28
+ // List Name
29
+ log.style(list.name, styles.list);
30
+
31
+ // List Locked
32
+ if ( list.locked ) {
33
+ log.style(" locked", "dim");
34
+ }
35
+
36
+ // List Archived
37
+ if ( list.archived ) {
38
+ log.style(" archived", "dim");
39
+ }
40
+
41
+ // List Smart Filter
42
+ if ( list.smart ) {
43
+ log.style(" " + list.filter, "blue");
44
+ }
45
+
46
+ log();
47
+ }
48
+
49
+ return finish();
50
+ });
51
+ });
52
+ }
53
+
54
+
55
+ module.exports = {
56
+ command: 'lists',
57
+ alias: 'l',
58
+ description: 'Display all lists',
59
+ action: action
60
+ };
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ const config = require('../utils/config.js');
4
+ const login = require('../utils/login.js');
5
+ const finish = require('../utils/finish.js');
6
+
7
+
8
+ /**
9
+ * This command removes any existing User information from the
10
+ * config files and starts the RTM auth process. A successful
11
+ * login will save the User information in the first default
12
+ * config file.
13
+ */
14
+ function action(args, env) {
15
+ config.removeUser();
16
+ login(function() {
17
+ return finish();
18
+ });
19
+ }
20
+
21
+
22
+ module.exports = {
23
+ command: 'login',
24
+ description: 'Add RTM User information',
25
+ action: action,
26
+ disableLogin: true
27
+ };
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const log = require('../utils/log.js');
4
+ const finish = require('../utils/finish.js');
5
+ const config = require('../utils/config.js');
6
+
7
+
8
+ /**
9
+ * This command removes any saved User information from the
10
+ * config files.
11
+ */
12
+ function action(args, env) {
13
+ log.spinner.start('Logging Out...');
14
+ config.removeUser();
15
+ let c = config.get();
16
+ if ( !c._user && !c.user ) {
17
+ log.spinner.success('Logged Out');
18
+ }
19
+ else {
20
+ log.spinner.error('Could not log out');
21
+ }
22
+ return finish();
23
+ }
24
+
25
+
26
+ module.exports = {
27
+ command: 'logout',
28
+ description: 'Remove RTM User information',
29
+ action: action,
30
+ disableLogin: true
31
+ };