File tree Expand file tree Collapse file tree 1 file changed +49
-1
lines changed Expand file tree Collapse file tree 1 file changed +49
-1
lines changed Original file line number Diff line number Diff line change 1
- ' use strict' ;
1
+ " use strict" ;
2
2
3
3
// TODO: Write the homework code in this file
4
+
5
+ const fs = require ( "fs" ) ;
6
+ const todos = require ( "./utility/utilityAdd" ) ;
7
+ const read = require ( "./utility/utilityRead" ) ;
8
+ const remove = require ( "./utility/utilityRemove" ) ;
9
+ const update = require ( "./utility/utilityUpdate" ) ;
10
+ const reset = require ( "./utility/utilityReset" ) ;
11
+ const help = require ( "./utility/utilityHelp" ) ;
12
+
13
+ let arg = process . argv ;
14
+ let command = arg [ 2 ] ;
15
+ let userInput = arg [ 3 ] ;
16
+ let userUpdateInput = arg [ 4 ] ;
17
+
18
+ switch ( command ) {
19
+ case "add" :
20
+ todos . utilityAdd ( userInput ) ;
21
+ break ;
22
+ case "list" :
23
+ read . utilityRead ( ) ;
24
+ break ;
25
+ case "remove" :
26
+ let int = parseInt ( userInput ) ;
27
+
28
+ if ( Number . isInteger ( int ) && int > 0 ) {
29
+ remove . utilityRemove ( userInput ) ;
30
+ } else {
31
+ console . log ( "Error : You need to enter a valid number" ) ;
32
+ }
33
+ break ;
34
+ case "update" :
35
+ let intUp = parseInt ( userInput ) ;
36
+
37
+ if ( Number . isInteger ( intUp ) && intUp > 0 ) {
38
+ update . utilityUpdate ( userInput , userUpdateInput ) ;
39
+ } else {
40
+ console . log ( "Error : You need to enter a valid number" ) ;
41
+ }
42
+ break ;
43
+ case "reset" :
44
+ reset . utilityReset ( ) ;
45
+ break ;
46
+ case "help" :
47
+ console . log ( help . help ) ;
48
+ break ;
49
+ default :
50
+ console . log ( help . help ) ;
51
+ }
You can’t perform that action at this time.
0 commit comments