File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11const program = require ( 'commander' )
2- const chalk = require ( 'chalk ' )
2+ const colour = require ( '../lib/util/colour ' )
33const actions = require ( './actions' )
44
55require ( '../lib/util/enhanceErrorMessages' )
@@ -12,21 +12,21 @@ function tymlyCli (argv) {
1212 program
1313 . command ( 'init [blueprint-name]' )
1414 . description ( 'create a new Tymly blueprint' )
15- . action ( ( cmd , options ) => {
16- actions . init ( cmd , options )
15+ . action ( ( blueprintName , options ) => {
16+ actions . init ( blueprintName , options )
1717 } )
1818
1919 program
2020 . arguments ( '<command>' )
2121 . action ( ( cmd ) => {
2222 program . outputHelp ( )
23- console . log ( `${ chalk . red ( 'Unknown command' ) } ${ chalk . yellow ( cmd ) } .` )
23+ console . log ( `${ colour . red ( 'Unknown command' ) } ${ colour . yellow ( cmd ) } .` )
2424 console . log ( )
2525 } )
2626
2727 program . on ( '--help' , ( ) => {
2828 console . log ( )
29- console . log ( `Run ${ chalk . cyan ( `tymly <command> --help` ) } for detailed usage of given command.` )
29+ console . log ( `Run ${ colour . cyan ( `tymly <command> --help` ) } for detailed usage of given command.` )
3030 console . log ( )
3131 } )
3232
Original file line number Diff line number Diff line change 1+ const color = require ( 'ansi-color' ) . set
2+
3+ console . log ( color )
4+
5+ function c ( colorName ) {
6+ return text => color ( text , colorName )
7+ }
8+
9+ module . exports = {
10+ red : c ( 'red' ) ,
11+ yellow : c ( 'yellow' ) ,
12+ cyan : c ( 'cyan' )
13+ }
Original file line number Diff line number Diff line change 11const program = require ( 'commander' )
2- const chalk = require ( 'chalk ' )
2+ const colour = require ( './colour ' )
33
44function enhanceErrorMessages ( methodName , log ) {
55 program . Command . prototype [ methodName ] = function ( ...args ) {
66 if ( methodName === 'unknownOption' && this . _allowUnknownOption ) {
77 return
88 }
99 this . outputHelp ( )
10- console . log ( chalk . red ( log ( ...args ) ) )
10+ console . log ( colour . red ( log ( ...args ) ) )
1111 console . log ( )
1212 }
1313}
1414
1515enhanceErrorMessages ( 'missingArgument' , argName => {
16- return `\nMissing required argument ${ chalk . yellow ( `<${ argName } >` ) } .`
16+ return `\nMissing required argument ${ colour . yellow ( `<${ argName } >` ) } .`
1717} )
1818
1919enhanceErrorMessages ( 'unknownOption' , optionName => {
20- return `\nUnknown option ${ chalk . yellow ( optionName ) } .`
20+ return `\nUnknown option ${ colour . yellow ( optionName ) } .`
2121} )
2222
2323enhanceErrorMessages ( 'optionMissingArgument' , ( option , flag ) => {
24- return `Missing required argument for option ${ chalk . yellow ( option . flags ) } ` + (
25- flag ? `, got ${ chalk . yellow ( flag ) } ` : ``
24+ return `Missing required argument for option ${ colour . yellow ( option . flags ) } ` + (
25+ flag ? `, got ${ colour . yellow ( flag ) } ` : ``
2626 )
2727} )
2828
Original file line number Diff line number Diff line change 2323 "tymly" : " bin/tymly-cli.js"
2424 },
2525 "dependencies" : {
26- "chalk" : " 2.4.2" ,
27- "commander" : " 2.19.0"
26+ "@wmfs/tymly-scaffold" : " 1.0.0" ,
27+ "ansi-color" : " 0.2.1" ,
28+ "commander" : " 2.19.0" ,
29+ "enquirer" : " 2.3.0"
2830 },
2931 "devDependencies" : {
3032 "@semantic-release/changelog" : " 3.0.1" ,
You can’t perform that action at this time.
0 commit comments