1 | # `@diez/cli-core`
|
2 |
|
3 | This package provides the core functionality of the extensible Diez command line interface.
|
4 |
|
5 | Diez configurations, which can be specified either in `package.json` using the special `"diez"` key or in a dedicated `.diezrc` file, can extend the command line functionality in various ways, including registering compiler targets and providing entire new commands.
|
6 |
|
7 | A `CliCommandProvider` can be implemented in a Diez package like this:
|
8 |
|
9 | ```
|
10 | // src/commands/command.ts
|
11 | import {CliCommandProvider} from '@diez/cli-core';
|
12 |
|
13 | const provider: CliCommandProvider = {
|
14 | loadAction: () => action,
|
15 | name: 'command',
|
16 | description: 'Command description',
|
17 | options: [
|
18 | {
|
19 | shortName: 'o',
|
20 | longName: 'option',
|
21 | valueName: 'optionValue',
|
22 | description: 'Some option.',
|
23 | },
|
24 | ],
|
25 | };
|
26 |
|
27 | export = provider;
|
28 | ```
|
29 |
|
30 | A custom command provider can be registered in `package-name/package.json`:
|
31 |
|
32 | ```
|
33 | {
|
34 | "name": "package-name",
|
35 | ...,
|
36 | "diez": {
|
37 | "providers": {
|
38 | "commands": ["./lib/commands/command"]
|
39 | }
|
40 | }
|
41 | }
|
42 | ```
|
43 |
|
44 | or in `package-name/.diezrc`:
|
45 |
|
46 | ```
|
47 | {
|
48 | "providers": {
|
49 | "commands": ["./lib/commands/command"]
|
50 | }
|
51 | }
|
52 | ```
|
53 |
|
54 | The resulting command can be invoked with: `diez command --option [-o] <optionValue>`.
|