11'use strict' ;
22var fs = require ( 'fs' ) ;
33
4+ var sprintf = require ( 'sprintf-js' ) . sprintf ;
5+
46var h = require ( '../helper' ) ;
57var chalk = require ( '../chalk' ) ;
68var config = require ( '../config' ) ;
@@ -60,6 +62,17 @@ const cmd = {
6062 }
6163} ;
6264
65+ function printPlugins ( plugins ) {
66+ log . info ( chalk . gray ( sprintf ( ' %6s %-18s %-15s %s' , 'Active' , 'Name' , 'Version' , 'Desc' ) ) ) ;
67+ log . info ( chalk . gray ( '-' . repeat ( 100 ) ) ) ;
68+
69+ plugins = plugins || Plugin . plugins ;
70+ for ( let p of plugins )
71+ log . printf ( ' %s %-18s %-15s %s' ,
72+ h . prettyText ( '' , p . enabled ) , p . name , p . ver , p . desc ) ;
73+ Plugin . save ( ) ;
74+ }
75+
6376cmd . handler = function ( argv ) {
6477 session . argv = argv ;
6578
@@ -83,17 +96,18 @@ cmd.handler = function(argv) {
8396
8497 if ( argv . enable ) {
8598 plugin . enable ( true ) ;
99+ printPlugins ( ) ;
86100 } else if ( argv . disable ) {
87101 plugin . enable ( false ) ;
102+ printPlugins ( ) ;
88103 } else if ( argv . delete ) {
89104 fs . unlink ( fullpath , function ( e ) {
90105 if ( e ) log . error ( e . message ) ;
91106 } ) ;
92107 } else if ( argv . config ) {
93108 log . info ( JSON . stringify ( config . plugins [ name ] || { } , null , 2 ) ) ;
94109 } else {
95- for ( let p of plugins )
96- log . printf ( '%s %-18s %-15s %s' , h . prettyText ( '' , p . enabled ) , p . name , p . ver , p . desc ) ;
110+ printPlugins ( plugins ) ;
97111 }
98112} ;
99113
0 commit comments