forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.ts
More file actions
36 lines (30 loc) · 1.03 KB
/
help.ts
File metadata and controls
36 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// tslint:disable:no-global-tslint-disable no-any file-header
import { terminal } from '@angular-devkit/core';
import { Command, Option } from '../models/command';
export default class HelpCommand extends Command {
public readonly name = 'help';
public readonly description = 'Help.';
public readonly arguments: string[] = [];
public readonly options: Option[] = [];
run(options: any) {
const commands = Object.keys(options.commandMap)
.map(key => {
const Cmd = options.commandMap[key];
const command: Command = new Cmd(null, null);
return command;
})
.filter(cmd => !cmd.hidden && !cmd.unknown)
.map(cmd => ({
name: cmd.name,
description: cmd.description,
}));
this.logger.info(`Available Commands:`);
commands.forEach(cmd => {
this.logger.info(` ${terminal.cyan(cmd.name)} ${cmd.description}`);
});
this.logger.info(`\nFor more detailed help run "ng [command name] --help"`);
}
printHelp(options: any) {
return this.run(options);
}
}