@@ -116,46 +116,60 @@ export abstract class SchematicCommand<
116
116
await super . printHelp ( options ) ;
117
117
this . logger . info ( '' ) ;
118
118
119
- const schematicNames = Object . keys ( this . description . suboptions || { } ) ;
119
+ const subCommandOption = this . description . options . filter ( x => x . subcommands ) [ 0 ] ;
120
120
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
+ }
124
124
125
- const namesPerCollection : { [ c : string ] : string [ ] } = { } ;
126
- schematicNames . forEach ( name => {
127
- const [ collectionName , schematicName ] = name . split ( / : / , 2 ) ;
125
+ const schematicNames = Object . keys ( subCommandOption . subcommands ) ;
128
126
129
- if ( ! namesPerCollection [ collectionName ] ) {
130
- namesPerCollection [ collectionName ] = [ ] ;
131
- }
127
+ if ( schematicNames . length > 1 ) {
128
+ this . logger . info ( 'Available Schematics:' ) ;
132
129
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
+ }
135
137
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
+ } ) ;
142
144
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 } ` ) ;
146
154
} ) ;
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 ] ] ) ;
151
159
}
152
160
153
161
return 0 ;
154
162
}
155
163
156
164
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 ) {
159
173
this . logger . info ( this . description . description ) ;
160
174
161
175
const opts = this . description . options . filter ( x => x . positional === undefined ) ;
@@ -167,7 +181,7 @@ export abstract class SchematicCommand<
167
181
? schematicName
168
182
: schematicNames [ 0 ] ;
169
183
170
- const schematicOptions = this . description . suboptions [ schematicNames [ 0 ] ] ;
184
+ const schematicOptions = subCommandOption . subcommands [ schematicNames [ 0 ] ] . options ;
171
185
const schematicArgs = schematicOptions . filter ( x => x . positional !== undefined ) ;
172
186
const argDisplay = schematicArgs . length > 0
173
187
? ' ' + schematicArgs . map ( a => `<${ strings . dasherize ( a . name ) } >` ) . join ( ' ' )
0 commit comments