File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,6 @@ export class GenerateCommand extends SchematicCommand {
48
48
const [ collectionName , schematicName ] = this . parseSchematicInfo ( options ) ;
49
49
50
50
// remove the schematic name from the options
51
- // options._ = options._.slice(1);
52
51
delete options . schematic ;
53
52
54
53
return this . runSchematic ( {
Original file line number Diff line number Diff line change @@ -63,18 +63,24 @@ export abstract class Command<T = any> {
63
63
this . printHelpOptions ( this . options ) ;
64
64
}
65
65
66
- private getArgIndex ( def : OptionSmartDefault | undefined ) : number {
67
- if ( def === undefined || def . index === undefined || typeof def . index !== 'number' ) {
68
- return 99999 ;
66
+ private _getArguments ( options : Option [ ] ) {
67
+ function _getArgIndex ( def : OptionSmartDefault | undefined ) : number {
68
+ if ( def === undefined || def . $source !== 'argv' || typeof def . index !== 'number' ) {
69
+ // If there's no proper order, this argument is wonky. We will show it at the end only
70
+ // (after all other arguments).
71
+ return Infinity ;
72
+ }
73
+
74
+ return def . index ;
69
75
}
70
76
71
- return def . index ;
77
+ return options
78
+ . filter ( opt => this . isArgument ( opt ) )
79
+ . sort ( ( a , b ) => _getArgIndex ( a . $default ) - _getArgIndex ( b . $default ) ) ;
72
80
}
73
81
74
82
protected printHelpUsage ( name : string , options : Option [ ] ) {
75
- const args = options
76
- . filter ( opt => this . isArgument ( opt ) )
77
- . sort ( ( a , b ) => this . getArgIndex ( a . $default ) - this . getArgIndex ( b . $default ) ) ;
83
+ const args = this . _getArguments ( options ) ;
78
84
const opts = options . filter ( opt => ! this . isArgument ( opt ) ) ;
79
85
const argDisplay = args && args . length > 0
80
86
? ' ' + args . map ( a => `<${ a . name } >` ) . join ( ' ' )
You can’t perform that action at this time.
0 commit comments