1 | import { Option as CommanderOption, program } from 'commander';
|
2 | import { satisfies as semverSatisfies } from 'semver';
|
3 | import { commandCheck } from './commandCheck.js';
|
4 | import { commandLink } from './commandLink.js';
|
5 | import { commandLint } from './commandLint.js';
|
6 | import { commandSuggestion } from './commandSuggestion.js';
|
7 | import { commandTrace } from './commandTrace.js';
|
8 | import { npmPackage } from './pkgInfo.js';
|
9 | import { ApplicationError } from './util/errors.js';
|
10 | export { ApplicationError, CheckFailed } from './util/errors.js';
|
11 | export async function run(command, argv) {
|
12 | const prog = command || program;
|
13 | const args = argv || process.argv;
|
14 | prog.exitOverride();
|
15 | prog.version(npmPackage.version).description('Spelling Checker for Code').name('cspell');
|
16 | if (!semverSatisfies(process.versions.node, npmPackage.engines.node)) {
|
17 | throw new ApplicationError(`Unsupported NodeJS version (${process.versions.node}); ${npmPackage.engines.node} is required`);
|
18 | }
|
19 | const optionFlags = new CommanderOption('-f,--flag <flag:value>', 'Declare an execution flag value')
|
20 | .hideHelp()
|
21 | .argParser((value, prev) => prev?.concat(value) || [value]);
|
22 | commandLint(prog).addOption(optionFlags);
|
23 | commandTrace(prog).addOption(optionFlags);
|
24 | commandCheck(prog).addOption(optionFlags);
|
25 | commandSuggestion(prog).addOption(optionFlags);
|
26 | commandLink(prog);
|
27 | |
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | prog.exitOverride();
|
43 | await prog.parseAsync(args);
|
44 | }
|
45 |
|
\ | No newline at end of file |