File tree Expand file tree Collapse file tree 6 files changed +73
-11
lines changed
tools/office-cmdlet-updater Expand file tree Collapse file tree 6 files changed +73
-11
lines changed Original file line number Diff line number Diff line change 1
1
{
2
+ "name" : " Office cmdlet updater" ,
3
+ "description" : " Update documentation for modules in this repository" ,
4
+ "version" : " 0.0.3" ,
2
5
"platyPS" : {
3
6
"credentials" : {
4
7
"login" : " " ,
Original file line number Diff line number Diff line change
1
+ class CliController {
2
+ constructor ( cliService ) {
3
+ this . cliServoce = cliService ;
4
+ }
5
+
6
+ startCli ( argv ) {
7
+ this . cliServoce . addOption ( {
8
+ option : '-m --module <module>' ,
9
+ description : 'update documentation for module' ,
10
+ defaultValue : 'all'
11
+ } ) ;
12
+
13
+ this . cliServoce . addOption ( {
14
+ option : '-c --cmdlet <cmdet>' ,
15
+ description : 'update documentation for cmdlet in module'
16
+ } ) ;
17
+
18
+ this . cliServoce . start ( argv , ( cli ) => {
19
+ const { module, cmdlet } = cli ;
20
+
21
+ console . log ( module ) ;
22
+ console . log ( cmdlet ) ;
23
+ } ) ;
24
+ }
25
+ }
26
+
27
+ module . exports = CliController ;
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ const MarkdownController = require('../controllers/markdown.controller');
9
9
const db = require ( '../db' ) ( ) ;
10
10
const CmdletDependenciesService = require ( '../services/cmdlet.dependencies.service' ) ;
11
11
const FsService = require ( '../services/fs.service' ) ;
12
+ const CliService = require ( '../services/cli.service' ) ;
13
+ const CliController = require ( '../controllers/cli.controller' ) ;
12
14
13
15
module . exports = ( ) => {
14
16
const container = awilix . createContainer ( {
@@ -22,6 +24,7 @@ module.exports = () => {
22
24
} ) ;
23
25
24
26
container . register ( {
27
+ cliService : awilix . asClass ( CliService ) . singleton ( ) ,
25
28
mailNotificationService : awilix
26
29
. asClass ( MailNotificationService )
27
30
. singleton ( ) ,
@@ -32,11 +35,12 @@ module.exports = () => {
32
35
. asClass ( CmdletDependenciesService )
33
36
. singleton ( ) ,
34
37
fsService : awilix . asClass ( FsService ) . singleton ( ) ,
35
- markdownService : awilix . asClass ( MarkdownService ) . singleton ( )
36
- } ) ;
38
+ markdownService : awilix . asClass ( MarkdownService ) . singleton ( )
39
+ } ) ;
37
40
38
41
container . register ( {
39
- markdownController : awilix . asClass ( MarkdownController ) . singleton ( )
42
+ markdownController : awilix . asClass ( MarkdownController ) . singleton ( ) ,
43
+ cliController : awilix . asClass ( CliController ) . singleton ( )
40
44
} ) ;
41
45
42
46
return container ;
Original file line number Diff line number Diff line change 1
1
const container = require ( './helpers/di.container' ) ( ) ;
2
2
3
- ( async function ( ) {
4
- try {
5
- const markdownController = container . resolve ( 'markdownController' ) ;
3
+ try {
4
+ const cliController = container . resolve ( 'cliController' ) ;
6
5
7
- await markdownController . updateMarkdown ( ) ;
8
- } catch ( e ) {
9
- console . log ( e ) ;
10
- }
11
- } ) ( ) ;
6
+ cliController . startCli ( process . argv ) ;
7
+ } catch ( e ) {
8
+ console . log ( e ) ;
9
+ }
Original file line number Diff line number Diff line change 27
27
"await-of" : " ^1.1.2" ,
28
28
"awilix" : " ^3.0.9" ,
29
29
"better-queue" : " ^3.8.10" ,
30
+ "commander" : " ^2.19.0" ,
30
31
"config" : " ^2.0.1" ,
31
32
"fs-extra" : " ^7.0.0" ,
32
33
"lowdb" : " ^1.0.0" ,
Original file line number Diff line number Diff line change
1
+ const cli = require ( 'commander' ) ;
2
+
3
+ class CliService {
4
+ constructor ( config ) {
5
+ this . config = config ;
6
+ this . cli = cli ;
7
+
8
+ const { description, version } = config ;
9
+
10
+ this . cli . version ( version , '-v, --version' ) . description ( description ) ;
11
+ }
12
+
13
+ addOption ( {
14
+ option,
15
+ description = '' ,
16
+ defaultValue = '' ,
17
+ action = ( ) => { }
18
+ } ) {
19
+ this . cli . option ( option , description , defaultValue ) . action ( action ) ;
20
+ }
21
+
22
+ start ( argv , cb = ( ) => { } ) {
23
+ this . cli . parse ( argv ) ;
24
+
25
+ cb ( this . cli ) ;
26
+ }
27
+ }
28
+
29
+ module . exports = CliService ;
You can’t perform that action at this time.
0 commit comments