@beauraines/rtm-cli 1.6.1 → 1.7.0

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.7.0](https://github.com/beauraines/rtm-cli/compare/v1.6.1...v1.7.0) (2023-03-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * adds ability to add notes to tasks ([#31](https://github.com/beauraines/rtm-cli/issues/31)) ([f262ec6](https://github.com/beauraines/rtm-cli/commit/f262ec6f02d024a5f3c49e10f79db2c6fabcf0fa)), closes [#23](https://github.com/beauraines/rtm-cli/issues/23)
11
+
5
12
  ### [1.6.1](https://github.com/beauraines/rtm-cli/compare/v1.6.0...v1.6.1) (2023-03-06)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beauraines/rtm-cli",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "RTM CLI",
5
5
  "keywords": [
6
6
  "rtm",
@@ -0,0 +1,93 @@
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:', 'Title:', 'Body:', _promptFinished);
20
+ } else if (args.length = 2 ) {
21
+ _process(args[0],'',args[1])
22
+ }
23
+
24
+ // Use provided args
25
+ else {
26
+ _process(args[0], args[1], args[2]);
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], answer[1], answer[2],i+1, answers.length);
40
+ }
41
+ }
42
+
43
+
44
+ /**
45
+ * Process the request
46
+ * @private
47
+ */
48
+ function _process(index, title, body, count=1, max=1) {
49
+
50
+ // Display info
51
+ log.spinner.start("Updating Task(s)...");
52
+
53
+ // Get User
54
+ config.user(function(user) {
55
+
56
+ // Parse arguments
57
+ index = parseInt(index.trim());
58
+
59
+ // Add Notes
60
+ user.tasks.addNotes(index, title, body, function(err) {
61
+ if ( err ) {
62
+ log.spinner.error("Could not add notes for Task #" + index + " (" + err.msg + ")");
63
+ }
64
+ _processFinished(count, max);
65
+ });
66
+
67
+ });
68
+
69
+ }
70
+
71
+ /**
72
+ * Request Callback
73
+ * @private
74
+ */
75
+ function _processFinished(count, max) {
76
+ log.spinner.start("Updating Task [" + count + "/" + max + "]...");
77
+
78
+ // All tasks returned...
79
+ if ( count === max ) {
80
+ log.spinner.stop();
81
+ return finish();
82
+ }
83
+
84
+
85
+ }
86
+
87
+
88
+ module.exports = {
89
+ command: 'addNote [index] [title] [body]',
90
+ alias:'addNotes',
91
+ description: 'Add note or prompt for the title and body of the note. If only an index and text are included the text will be the body of the note without a title',
92
+ action: action
93
+ };