File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ module . exports = {
2+ init : require ( './init' )
3+ }
Original file line number Diff line number Diff line change 1+ function initAction ( blueprintName , options ) {
2+ console . log ( "Yes lads" )
3+ }
4+
5+ module . exports = initAction
Original file line number Diff line number Diff line change 11const program = require ( 'commander' )
2+ const chalk = require ( 'chalk' )
3+ const actions = require ( './actions' )
4+
5+ require ( '../lib/util/enhanceErrorMessages' )
26
37function tymlyCli ( argv ) {
48 program
59 . version ( require ( '../package' ) . version )
610 . usage ( '<command> [options]' )
711
12+ program
13+ . command ( 'init [blueprint-name]' )
14+ . description ( 'create a new Tymly blueprint' )
15+ . action ( ( cmd , options ) => {
16+ actions . init ( cmd , options )
17+ } )
18+
19+ program
20+ . arguments ( '<command>' )
21+ . action ( ( cmd ) => {
22+ program . outputHelp ( )
23+ console . log ( `${ chalk . red ( 'Unknown command' ) } ${ chalk . yellow ( cmd ) } .` )
24+ console . log ( )
25+ } )
26+
27+ program . on ( '--help' , ( ) => {
28+ console . log ( )
29+ console . log ( `Run ${ chalk . cyan ( `tymly <command> --help` ) } for detailed usage of given command.` )
30+ console . log ( )
31+ } )
32+
833 program . parse ( argv )
934
1035 if ( ! argv . slice ( 2 ) . length ) {
Original file line number Diff line number Diff line change 1+ const program = require ( 'commander' )
2+ const chalk = require ( 'chalk' )
3+
4+ function enhanceErrorMessages ( methodName , log ) {
5+ program . Command . prototype [ methodName ] = function ( ...args ) {
6+ if ( methodName === 'unknownOption' && this . _allowUnknownOption ) {
7+ return
8+ }
9+ this . outputHelp ( )
10+ console . log ( chalk . red ( log ( ...args ) ) )
11+ console . log ( )
12+ }
13+ }
14+
15+ enhanceErrorMessages ( 'missingArgument' , argName => {
16+ return `\nMissing required argument ${ chalk . yellow ( `<${ argName } >` ) } .`
17+ } )
18+
19+ enhanceErrorMessages ( 'unknownOption' , optionName => {
20+ return `\nUnknown option ${ chalk . yellow ( optionName ) } .`
21+ } )
22+
23+ enhanceErrorMessages ( 'optionMissingArgument' , ( option , flag ) => {
24+ return `Missing required argument for option ${ chalk . yellow ( option . flags ) } ` + (
25+ flag ? `, got ${ chalk . yellow ( flag ) } ` : ``
26+ )
27+ } )
28+
29+ module . exports = enhanceErrorMessages
You can’t perform that action at this time.
0 commit comments