@@ -17,7 +17,7 @@ import { SchematicAvailableOptions } from '../tasks/schematic-get-options';
1717const Command = require ( '../ember-cli/lib/models/command' ) ;
1818const SilentError = require ( 'silent-error' ) ;
1919
20- const { cyan, yellow } = chalk ;
20+ const { cyan, grey , yellow } = chalk ;
2121const separatorRegEx = / [ \/ \\ ] / g;
2222
2323
@@ -186,15 +186,57 @@ export default Command.extend({
186186 } ) ;
187187 } ,
188188
189- printDetailedHelp : function ( ) {
189+ printDetailedHelp : function ( _options : any , rawArgs : any ) : string | Promise < string > {
190190 const engineHost = getEngineHost ( ) ;
191191 const collectionName = this . getCollectionName ( ) ;
192192 const collection = getCollection ( collectionName ) ;
193- const schematicNames : string [ ] = engineHost . listSchematics ( collection ) ;
194- this . ui . writeLine ( cyan ( 'Available schematics:' ) ) ;
195- schematicNames . forEach ( schematicName => {
196- this . ui . writeLine ( yellow ( ` ${ schematicName } ` ) ) ;
197- } ) ;
198- this . ui . writeLine ( '' ) ;
193+ const schematicName = rawArgs [ 1 ] ;
194+ if ( schematicName ) {
195+ const SchematicGetOptionsTask = require ( '../tasks/schematic-get-options' ) . default ;
196+ const getOptionsTask = new SchematicGetOptionsTask ( {
197+ ui : this . ui ,
198+ project : this . project
199+ } ) ;
200+ return getOptionsTask . run ( {
201+ schematicName,
202+ collectionName
203+ } )
204+ . then ( ( availableOptions : SchematicAvailableOptions [ ] ) => {
205+ const output : string [ ] = [ ] ;
206+ output . push ( cyan ( `ng generate ${ schematicName } ${ cyan ( '[name]' ) } ${ cyan ( '<options...>' ) } ` ) ) ;
207+ availableOptions
208+ . filter ( opt => opt . name !== 'name' )
209+ . forEach ( opt => {
210+ let text = cyan ( ` --${ opt . name } ` ) ;
211+ if ( opt . schematicType ) {
212+ text += cyan ( ` (${ opt . schematicType } )` ) ;
213+ }
214+ if ( opt . schematicDefault ) {
215+ text += cyan ( ` (Default: ${ opt . schematicDefault } )` ) ;
216+ }
217+ if ( opt . description ) {
218+ text += ` ${ opt . description } ` ;
219+ }
220+ output . push ( text ) ;
221+ if ( opt . aliases && opt . aliases . length > 0 ) {
222+ const aliasText = opt . aliases . reduce (
223+ ( acc , curr ) => {
224+ return acc + ` -${ curr } ` ;
225+ } ,
226+ '' ) ;
227+ output . push ( grey ( ` aliases: ${ aliasText } ` ) ) ;
228+ }
229+ } ) ;
230+ return output . join ( '\n' ) ;
231+ } ) ;
232+ } else {
233+ const schematicNames : string [ ] = engineHost . listSchematics ( collection ) ;
234+ const output : string [ ] = [ ] ;
235+ output . push ( cyan ( 'Available schematics:' ) ) ;
236+ schematicNames . forEach ( schematicName => {
237+ output . push ( yellow ( ` ${ schematicName } ` ) ) ;
238+ } ) ;
239+ return Promise . resolve ( output . join ( '\n' ) ) ;
240+ }
199241 }
200242} ) ;
0 commit comments