@@ -116,46 +116,60 @@ export abstract class SchematicCommand<
116116 await super . printHelp ( options ) ;
117117 this . logger . info ( '' ) ;
118118
119- const schematicNames = Object . keys ( this . description . suboptions || { } ) ;
119+ const subCommandOption = this . description . options . filter ( x => x . subcommands ) [ 0 ] ;
120120
121- if ( this . description . suboptions ) {
122- if ( schematicNames . length > 1 ) {
123- this . logger . info ( 'Available Schematics:' ) ;
121+ if ( ! subCommandOption || ! subCommandOption . subcommands ) {
122+ return 0 ;
123+ }
124124
125- const namesPerCollection : { [ c : string ] : string [ ] } = { } ;
126- schematicNames . forEach ( name => {
127- const [ collectionName , schematicName ] = name . split ( / : / , 2 ) ;
125+ const schematicNames = Object . keys ( subCommandOption . subcommands ) ;
128126
129- if ( ! namesPerCollection [ collectionName ] ) {
130- namesPerCollection [ collectionName ] = [ ] ;
131- }
127+ if ( schematicNames . length > 1 ) {
128+ this . logger . info ( 'Available Schematics:' ) ;
132129
133- namesPerCollection [ collectionName ] . push ( schematicName ) ;
134- } ) ;
130+ const namesPerCollection : { [ c : string ] : string [ ] } = { } ;
131+ schematicNames . forEach ( name => {
132+ let [ collectionName , schematicName ] = name . split ( / : / , 2 ) ;
133+ if ( ! schematicName ) {
134+ schematicName = collectionName ;
135+ collectionName = this . collectionName ;
136+ }
135137
136- const defaultCollection = this . getDefaultSchematicCollection ( ) ;
137- Object . keys ( namesPerCollection ) . forEach ( collectionName => {
138- const isDefault = defaultCollection == collectionName ;
139- this . logger . info (
140- ` Collection " ${ collectionName } " ${ isDefault ? ' (default)' : '' } :` ,
141- ) ;
138+ if ( ! namesPerCollection [ collectionName ] ) {
139+ namesPerCollection [ collectionName ] = [ ] ;
140+ }
141+
142+ namesPerCollection [ collectionName ] . push ( schematicName ) ;
143+ } ) ;
142144
143- namesPerCollection [ collectionName ] . forEach ( schematicName => {
144- this . logger . info ( ` ${ schematicName } ` ) ;
145- } ) ;
145+ const defaultCollection = this . getDefaultSchematicCollection ( ) ;
146+ Object . keys ( namesPerCollection ) . forEach ( collectionName => {
147+ const isDefault = defaultCollection == collectionName ;
148+ this . logger . info (
149+ ` Collection "${ collectionName } "${ isDefault ? ' (default)' : '' } :` ,
150+ ) ;
151+
152+ namesPerCollection [ collectionName ] . forEach ( schematicName => {
153+ this . logger . info ( ` ${ schematicName } ` ) ;
146154 } ) ;
147- } else if ( schematicNames . length == 1 ) {
148- this . logger . info ( 'Options for schematic ' + schematicNames [ 0 ] ) ;
149- await this . printHelpOptions ( this . description . suboptions [ schematicNames [ 0 ] ] ) ;
150- }
155+ } ) ;
156+ } else if ( schematicNames . length == 1 ) {
157+ this . logger . info ( 'Help for schematic ' + schematicNames [ 0 ] ) ;
158+ await this . printHelpSubcommand ( subCommandOption . subcommands [ schematicNames [ 0 ] ] ) ;
151159 }
152160
153161 return 0 ;
154162 }
155163
156164 async printHelpUsage ( ) {
157- const schematicNames = Object . keys ( this . description . suboptions || { } ) ;
158- if ( this . description . suboptions && schematicNames . length == 1 ) {
165+ const subCommandOption = this . description . options . filter ( x => x . subcommands ) [ 0 ] ;
166+
167+ if ( ! subCommandOption || ! subCommandOption . subcommands ) {
168+ return ;
169+ }
170+
171+ const schematicNames = Object . keys ( subCommandOption . subcommands ) ;
172+ if ( schematicNames . length == 1 ) {
159173 this . logger . info ( this . description . description ) ;
160174
161175 const opts = this . description . options . filter ( x => x . positional === undefined ) ;
@@ -167,7 +181,7 @@ export abstract class SchematicCommand<
167181 ? schematicName
168182 : schematicNames [ 0 ] ;
169183
170- const schematicOptions = this . description . suboptions [ schematicNames [ 0 ] ] ;
184+ const schematicOptions = subCommandOption . subcommands [ schematicNames [ 0 ] ] . options ;
171185 const schematicArgs = schematicOptions . filter ( x => x . positional !== undefined ) ;
172186 const argDisplay = schematicArgs . length > 0
173187 ? ' ' + schematicArgs . map ( a => `<${ strings . dasherize ( a . name ) } >` ) . join ( ' ' )
0 commit comments