forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiExtractorCommandLine.ts
More file actions
45 lines (36 loc) · 1.33 KB
/
ApiExtractorCommandLine.ts
File metadata and controls
45 lines (36 loc) · 1.33 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
37
38
39
40
41
42
43
44
45
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import * as colors from 'colors';
import * as os from 'os';
import { CommandLineParser, CommandLineFlagParameter } from '@microsoft/ts-command-line';
import { RunAction } from './RunAction';
export class ApiExtractorCommandLine extends CommandLineParser {
private _debugParameter: CommandLineFlagParameter;
constructor() {
super({
toolFilename: 'api-extractor',
toolDescription: 'This is an experimental command line interface for the API Extractor tool.'
});
this._populateActions();
}
protected onDefineParameters(): void { // override
this._debugParameter = this.defineFlagParameter({
parameterLongName: '--debug',
parameterShortName: '-d',
description: 'Show the full call stack if an error occurs while executing the tool'
});
}
protected onExecute(): Promise<void> { // override
return super.onExecute().catch((error) => {
if (this._debugParameter.value) {
console.error(os.EOL + error.stack);
} else {
console.error(os.EOL + colors.red('ERROR: ' + error.message.trim()));
}
process.exitCode = 1;
});
}
private _populateActions(): void {
this.addAction(new RunAction(this));
}
}