Skip to content

Commit a7b9ee5

Browse files
committed
refactor: cleanup and better documentation / comments (hidden from release log)
1 parent 2bf1228 commit a7b9ee5

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

packages/angular/cli/commands/generate-impl.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export class GenerateCommand extends SchematicCommand {
4848
const [collectionName, schematicName] = this.parseSchematicInfo(options);
4949

5050
// remove the schematic name from the options
51-
// options._ = options._.slice(1);
5251
delete options.schematic;
5352

5453
return this.runSchematic({

packages/angular/cli/models/command.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,24 @@ export abstract class Command<T = any> {
6363
this.printHelpOptions(this.options);
6464
}
6565

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;
6975
}
7076

71-
return def.index;
77+
return options
78+
.filter(opt => this.isArgument(opt))
79+
.sort((a, b) => _getArgIndex(a.$default) - _getArgIndex(b.$default));
7280
}
7381

7482
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);
7884
const opts = options.filter(opt => !this.isArgument(opt));
7985
const argDisplay = args && args.length > 0
8086
? ' ' + args.map(a => `<${a.name}>`).join(' ')

0 commit comments

Comments
 (0)