@@ -8,19 +8,33 @@ import moment = require('moment');
8
8
import chrono = require( 'chrono-node' ) ;
9
9
import { displayNumber , displayText } from './display.helper' ;
10
10
11
-
11
+ /**
12
+ * The main app class
13
+ */
12
14
export class App {
13
15
16
+ /**
17
+ * The api object used to communicate with Jira
18
+ */
14
19
api : JiraApi ;
15
20
21
+ /**
22
+ * The app's configuration
23
+ */
16
24
config : Conf ;
17
25
26
+ /**
27
+ * The JiraService that abstracts the actual logic to load data from and interact with Jira
28
+ */
18
29
service : JiraService ;
19
30
20
31
constructor ( ) {
21
32
22
33
}
23
34
35
+ /**
36
+ * Initialize the application
37
+ */
24
38
initialize ( ) : Promise < App > {
25
39
return this . _loadConfig ( ) . then ( ( ) => {
26
40
this . _initializeApi ( ) ;
@@ -29,6 +43,10 @@ export class App {
29
43
} ) ;
30
44
}
31
45
46
+ /**
47
+ * Load the backlog of the given project and display it
48
+ * @param project
49
+ */
32
50
backlog ( project : string ) {
33
51
this . service . getSprintsForProject ( project ) . then ( sprints => {
34
52
return sprints . filter ( sprint => sprint . state !== 'closed' )
@@ -44,6 +62,11 @@ export class App {
44
62
} ) ;
45
63
}
46
64
65
+ /**
66
+ * Load the board of the active sprint of the given project and display it
67
+ * @param project
68
+ * @param onlyMine
69
+ */
47
70
board ( project : string , onlyMine ?: boolean ) {
48
71
this . service . getDisplayBoardForProject ( project , onlyMine ) . then ( board => {
49
72
const maxWidth = ( process . stdout . columns || 80 ) - board . length ;
@@ -70,6 +93,11 @@ export class App {
70
93
} ) ;
71
94
}
72
95
96
+ /**
97
+ * Load the work log of the given user for the given date ad display it
98
+ * @param user
99
+ * @param date
100
+ */
73
101
worklog ( user = 'me' , date ?: string ) {
74
102
const parsedDate = ( date ) ? moment ( chrono . parseDate ( date ) ) : moment ( ) ;
75
103
this . service . getWorklogsForUser ( user , parsedDate ) . then ( worklogs => {
@@ -105,12 +133,22 @@ export class App {
105
133
} ) ;
106
134
}
107
135
136
+ /**
137
+ * Log a new work entry to the given issue
138
+ * @param issue
139
+ * @param duration
140
+ * @param start
141
+ * @param message
142
+ */
108
143
log ( issue : string , duration : number , start = new Date ( ) , message ?: string ) {
109
144
this . service . addWorkLogToIssue ( issue , duration , start , message ) . then ( response => {
110
145
// do nothing
111
146
} ) ;
112
147
}
113
148
149
+ /**
150
+ * Guide the user through the initial setup
151
+ */
114
152
init ( ) : Promise < string > {
115
153
return inquirer . prompt ( [
116
154
{
@@ -135,6 +173,10 @@ export class App {
135
173
} ) ;
136
174
}
137
175
176
+ /**
177
+ * Load the config from the config dir and return it in a Promise
178
+ * @private
179
+ */
138
180
private _loadConfig ( ) : Promise < Conf > {
139
181
this . config = new Conf ( {
140
182
encryptionKey : 'sdfyu7y3irfsov869wuvut7sdiyfuk'
@@ -147,10 +189,18 @@ export class App {
147
189
}
148
190
}
149
191
192
+ /**
193
+ * Inititalize the JiraApi interface
194
+ * @private
195
+ */
150
196
private _initializeApi ( ) {
151
197
this . api = new JiraApi ( this . config . get ( 'api' ) ) ;
152
198
}
153
199
200
+ /**
201
+ * Initialize the JiraService
202
+ * @private
203
+ */
154
204
private _initializeService ( ) {
155
205
this . service = new JiraService ( this . api ) ;
156
206
}
0 commit comments