@futdevpro/nts-dynamo 1.15.306 → 1.15.308
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/_collections/global-settings.const.d.ts.map +1 -1
- package/build/_collections/global-settings.const.js +1 -0
- package/build/_collections/global-settings.const.js.map +1 -1
- package/build/_models/interfaces/global-settings.interface.d.ts +6 -0
- package/build/_models/interfaces/global-settings.interface.d.ts.map +1 -1
- package/build/_modules/cli/_collections/cli-envelope.util.d.ts +52 -0
- package/build/_modules/cli/_collections/cli-envelope.util.d.ts.map +1 -0
- package/build/_modules/cli/_collections/cli-envelope.util.js +77 -0
- package/build/_modules/cli/_collections/cli-envelope.util.js.map +1 -0
- package/build/_modules/cli/_collections/cli-flag.util.d.ts +37 -0
- package/build/_modules/cli/_collections/cli-flag.util.d.ts.map +1 -0
- package/build/_modules/cli/_collections/cli-flag.util.js +174 -0
- package/build/_modules/cli/_collections/cli-flag.util.js.map +1 -0
- package/build/_modules/cli/_enums/cli-exit-code.type-enum.d.ts +20 -0
- package/build/_modules/cli/_enums/cli-exit-code.type-enum.d.ts.map +1 -0
- package/build/_modules/cli/_enums/cli-exit-code.type-enum.js +24 -0
- package/build/_modules/cli/_enums/cli-exit-code.type-enum.js.map +1 -0
- package/build/_modules/cli/_enums/cli-flag-value.type-enum.d.ts +16 -0
- package/build/_modules/cli/_enums/cli-flag-value.type-enum.d.ts.map +1 -0
- package/build/_modules/cli/_enums/cli-flag-value.type-enum.js +20 -0
- package/build/_modules/cli/_enums/cli-flag-value.type-enum.js.map +1 -0
- package/build/_modules/cli/_enums/cli-output.type-enum.d.ts +8 -0
- package/build/_modules/cli/_enums/cli-output.type-enum.d.ts.map +1 -0
- package/build/_modules/cli/_enums/cli-output.type-enum.js +12 -0
- package/build/_modules/cli/_enums/cli-output.type-enum.js.map +1 -0
- package/build/_modules/cli/_models/control-models/cli-command-params.control-model.d.ts +116 -0
- package/build/_modules/cli/_models/control-models/cli-command-params.control-model.d.ts.map +1 -0
- package/build/_modules/cli/_models/control-models/cli-command-params.control-model.js +237 -0
- package/build/_modules/cli/_models/control-models/cli-command-params.control-model.js.map +1 -0
- package/build/_modules/cli/_models/interfaces/cli-common-options.interface.d.ts +20 -0
- package/build/_modules/cli/_models/interfaces/cli-common-options.interface.d.ts.map +1 -0
- package/build/_modules/cli/_models/interfaces/cli-common-options.interface.js +3 -0
- package/build/_modules/cli/_models/interfaces/cli-common-options.interface.js.map +1 -0
- package/build/_modules/cli/_models/interfaces/cli-envelope.interface.d.ts +28 -0
- package/build/_modules/cli/_models/interfaces/cli-envelope.interface.d.ts.map +1 -0
- package/build/_modules/cli/_models/interfaces/cli-envelope.interface.js +3 -0
- package/build/_modules/cli/_models/interfaces/cli-envelope.interface.js.map +1 -0
- package/build/_modules/cli/_models/interfaces/cli-flag.interface.d.ts +47 -0
- package/build/_modules/cli/_models/interfaces/cli-flag.interface.d.ts.map +1 -0
- package/build/_modules/cli/_models/interfaces/cli-flag.interface.js +3 -0
- package/build/_modules/cli/_models/interfaces/cli-flag.interface.js.map +1 -0
- package/build/_modules/cli/_models/interfaces/cli-settings.interface.d.ts +25 -0
- package/build/_modules/cli/_models/interfaces/cli-settings.interface.d.ts.map +1 -0
- package/build/_modules/cli/_models/interfaces/cli-settings.interface.js +3 -0
- package/build/_modules/cli/_models/interfaces/cli-settings.interface.js.map +1 -0
- package/build/_modules/cli/_services/cli-program.control-service.d.ts +106 -0
- package/build/_modules/cli/_services/cli-program.control-service.d.ts.map +1 -0
- package/build/_modules/cli/_services/cli-program.control-service.js +271 -0
- package/build/_modules/cli/_services/cli-program.control-service.js.map +1 -0
- package/build/_modules/cli/index.d.ts +11 -0
- package/build/_modules/cli/index.d.ts.map +1 -1
- package/build/_modules/cli/index.js +15 -0
- package/build/_modules/cli/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type * as Commander from 'commander';
|
|
2
|
+
import { DyFM_Operation_Settings } from '@futdevpro/fsm-dynamo';
|
|
3
|
+
import { DyCLI_Output_Type } from '../../_enums/cli-output.type-enum';
|
|
4
|
+
import { DyCLI_CommonOptions } from '../interfaces/cli-common-options.interface';
|
|
5
|
+
import { DyCLI_Flag, DyCLI_Flag_Settings } from '../interfaces/cli-flag.interface';
|
|
6
|
+
import { DyCLI_ExitCodes, DyCLI_Settings } from '../interfaces/cli-settings.interface';
|
|
7
|
+
/** The values of a command call, keyed by parameter name — the same object an MCP `tools/call` sends as arguments. */
|
|
8
|
+
export type DyCLI_CommandValues = {
|
|
9
|
+
[param: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* One CLI command (HP-DOPL MP-4.2, decision D-4): ONE class for hand-written local commands and for commands
|
|
13
|
+
* generated from a server operation. With an `operation`, the flags come from the operation's input schema
|
|
14
|
+
* (`DyFM_OperationSchema_Util.inputSchema` — inputs, body properties, guardrail arguments), so the collected values are
|
|
15
|
+
* exactly the arguments of the MCP tool of the same operation. Without an operation (a local command of `dc`, `fdp` or
|
|
16
|
+
* `ma`), `action` runs the command.
|
|
17
|
+
*
|
|
18
|
+
* Custom options (D-4): per-parameter flag overrides and extra flags (`flags`), an own `action`, a `formatHuman` text
|
|
19
|
+
* formatter, `before` / `after` hooks, `output` and `exitCodes`. Defaults come from `DyNTS_global_settings.cli_settings`.
|
|
20
|
+
*
|
|
21
|
+
* `commander` is never loaded here: `buildCommand` receives the module loaded by `DyCLI_Commander_Util.load()`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const listTasks: DyCLI_Command_Params = new DyCLI_Command_Params({
|
|
26
|
+
* operation: listTasksOperation, // command: 'tasks.list'
|
|
27
|
+
* flags: { limit: { short: 'l' } },
|
|
28
|
+
* formatHuman: (tasks: Task[]): string => tasks.map((task: Task): string => task.title).join('\n'),
|
|
29
|
+
* });
|
|
30
|
+
* const commander: typeof Commander = await DyCLI_Commander_Util.load();
|
|
31
|
+
*
|
|
32
|
+
* program.addCommand(listTasks.buildCommand(commander, async (values: DyCLI_CommandValues): Promise<void> => {
|
|
33
|
+
* await runner.run(listTasks, values); // `--project-id p-1 -l 5` → { projectId: 'p-1', limit: 5 }
|
|
34
|
+
* }));
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class DyCLI_Command_Params {
|
|
38
|
+
/** The command name; default: the operation name (`<domain>.<action>`). */
|
|
39
|
+
readonly command: string;
|
|
40
|
+
/** The help description; default: the operation description. */
|
|
41
|
+
readonly description: string;
|
|
42
|
+
/** Alternative command names. */
|
|
43
|
+
readonly aliases: string[];
|
|
44
|
+
/** Extra help text shown after the options (examples). */
|
|
45
|
+
readonly helpText?: string;
|
|
46
|
+
/** The server operation the command calls; absent for a local command. */
|
|
47
|
+
readonly operation?: DyFM_Operation_Settings<unknown, unknown[], unknown>;
|
|
48
|
+
/** The resolved flags, in schema order, then the extra flags. */
|
|
49
|
+
readonly flags: DyCLI_Flag[];
|
|
50
|
+
/** The output of this command; absent = `cli_settings.output`, then `json`. */
|
|
51
|
+
readonly output?: DyCLI_Output_Type;
|
|
52
|
+
/** Exit-code overrides of this command. */
|
|
53
|
+
readonly exitCodes: Partial<DyCLI_ExitCodes>;
|
|
54
|
+
/** Where the params were constructed (for error diagnostics). */
|
|
55
|
+
readonly stackLocation: string;
|
|
56
|
+
/** Runs the command instead of calling the operation (required without an operation); `common` = the parsed common options. */
|
|
57
|
+
action?(values: DyCLI_CommandValues, params: DyCLI_Command_Params, common?: DyCLI_CommonOptions): Promise<unknown>;
|
|
58
|
+
/** The human-readable text of a result (output `human`). */
|
|
59
|
+
formatHuman?(result: unknown): string;
|
|
60
|
+
/** Runs before the command, e.g. to ensure a local server runs. */
|
|
61
|
+
before?(values: DyCLI_CommandValues, params: DyCLI_Command_Params): Promise<void>;
|
|
62
|
+
/** Runs after a successful command. */
|
|
63
|
+
after?(result: unknown, values: DyCLI_CommandValues, params: DyCLI_Command_Params): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* @param set - the command settings; throws a coded `DyFM_Error` (500 `DyNTS-CLP-*`) when invalid
|
|
66
|
+
*/
|
|
67
|
+
constructor(set: {
|
|
68
|
+
operation?: DyFM_Operation_Settings<unknown, unknown[], unknown>;
|
|
69
|
+
command?: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
aliases?: string[];
|
|
72
|
+
helpText?: string;
|
|
73
|
+
flags?: {
|
|
74
|
+
[param: string]: DyCLI_Flag_Settings;
|
|
75
|
+
};
|
|
76
|
+
output?: DyCLI_Output_Type;
|
|
77
|
+
exitCodes?: Partial<DyCLI_ExitCodes>;
|
|
78
|
+
action?(values: DyCLI_CommandValues, params: DyCLI_Command_Params, common?: DyCLI_CommonOptions): Promise<unknown>;
|
|
79
|
+
formatHuman?(result: unknown): string;
|
|
80
|
+
before?(values: DyCLI_CommandValues, params: DyCLI_Command_Params): Promise<void>;
|
|
81
|
+
after?(result: unknown, values: DyCLI_CommandValues, params: DyCLI_Command_Params): Promise<void>;
|
|
82
|
+
stackLocation?: string;
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Builds the commander command: name, description, aliases, help text and one option per flag; the action collects
|
|
86
|
+
* the typed values and hands them to `onAction`. A value that does not convert is a commander usage error.
|
|
87
|
+
* @param commander - the module from `DyCLI_Commander_Util.load()`
|
|
88
|
+
* @param onAction - receives the collected values
|
|
89
|
+
*/
|
|
90
|
+
buildCommand(commander: typeof Commander, onAction: (values: DyCLI_CommandValues) => Promise<void>): Commander.Command;
|
|
91
|
+
/**
|
|
92
|
+
* The values of a call from the parsed commander options: keyed by parameter name, defaults applied, absent flags
|
|
93
|
+
* left out.
|
|
94
|
+
* @param options - the parsed options (`command.opts()`)
|
|
95
|
+
*/
|
|
96
|
+
readValues(options: {
|
|
97
|
+
[attribute: string]: unknown;
|
|
98
|
+
}): DyCLI_CommandValues;
|
|
99
|
+
/** The output of this command: its own, then `cli_settings.output`, then `json`. */
|
|
100
|
+
getOutput(settings?: DyCLI_Settings | null): DyCLI_Output_Type;
|
|
101
|
+
/**
|
|
102
|
+
* The process exit code of a failure: a commander parse error or 400/404/422 → usage · 401/403 → auth · an
|
|
103
|
+
* unreachable server → network · any other status → remote · no status → operation error. The command's
|
|
104
|
+
* `exitCodes` win over `cli_settings.exitCodes`, which win over `DyCLI_ExitCode_Type`.
|
|
105
|
+
* @param error - the failure
|
|
106
|
+
* @param settings - the CLI settings (default: `DyNTS_global_settings.cli_settings`)
|
|
107
|
+
*/
|
|
108
|
+
exitCodeOf(error: unknown, settings?: DyCLI_Settings | null): number;
|
|
109
|
+
/** Builds the commander option of a flag. */
|
|
110
|
+
private static optionOf;
|
|
111
|
+
/** Validates the exit-code overrides: integers between 1 and 255 of known outcomes. */
|
|
112
|
+
private static checkExitCodes;
|
|
113
|
+
/** Builds the construction error with a stable error code and the construction location. */
|
|
114
|
+
private static invalid;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=cli-command-params.control-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-command-params.control-model.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/cli/_models/control-models/cli-command-params.control-model.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,SAAS,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAiD,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAM/G,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAUvF,sHAAsH;AACtH,MAAM,MAAM,mBAAmB,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE/D;;;;;;;;;;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H,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,GAAE,cAAc,GAAG,IAAyC,GAAG,MAAM;IAiCxG,6CAA6C;IAC7C,OAAO,CAAC,MAAM,CAAC,QAAQ;IA4BvB,uFAAuF;IACvF,OAAO,CAAC,MAAM,CAAC,cAAc;IAa7B,4FAA4F;IAC5F,OAAO,CAAC,MAAM,CAAC,OAAO;CAQvB"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DyCLI_Command_Params = void 0;
|
|
4
|
+
const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
|
|
5
|
+
const global_settings_const_1 = require("../../../../_collections/global-settings.const");
|
|
6
|
+
const cli_flag_util_1 = require("../../_collections/cli-flag.util");
|
|
7
|
+
const cli_exit_code_type_enum_1 = require("../../_enums/cli-exit-code.type-enum");
|
|
8
|
+
const cli_flag_value_type_enum_1 = require("../../_enums/cli-flag-value.type-enum");
|
|
9
|
+
const cli_output_type_enum_1 = require("../../_enums/cli-output.type-enum");
|
|
10
|
+
/** Command names: letters, digits, `.`, `_`, `-` (an operation name `<domain>.<action>` fits), max 64 characters. */
|
|
11
|
+
const DyCLI_commandName = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
12
|
+
/** Error codes of a server that can not be reached. */
|
|
13
|
+
const DyCLI_networkCodes = [
|
|
14
|
+
'ECONNREFUSED', 'ECONNRESET', 'ENOTFOUND', 'ETIMEDOUT', 'EAI_AGAIN', 'UND_ERR_CONNECT_TIMEOUT', 'UND_ERR_SOCKET',
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* One CLI command (HP-DOPL MP-4.2, decision D-4): ONE class for hand-written local commands and for commands
|
|
18
|
+
* generated from a server operation. With an `operation`, the flags come from the operation's input schema
|
|
19
|
+
* (`DyFM_OperationSchema_Util.inputSchema` — inputs, body properties, guardrail arguments), so the collected values are
|
|
20
|
+
* exactly the arguments of the MCP tool of the same operation. Without an operation (a local command of `dc`, `fdp` or
|
|
21
|
+
* `ma`), `action` runs the command.
|
|
22
|
+
*
|
|
23
|
+
* Custom options (D-4): per-parameter flag overrides and extra flags (`flags`), an own `action`, a `formatHuman` text
|
|
24
|
+
* formatter, `before` / `after` hooks, `output` and `exitCodes`. Defaults come from `DyNTS_global_settings.cli_settings`.
|
|
25
|
+
*
|
|
26
|
+
* `commander` is never loaded here: `buildCommand` receives the module loaded by `DyCLI_Commander_Util.load()`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const listTasks: DyCLI_Command_Params = new DyCLI_Command_Params({
|
|
31
|
+
* operation: listTasksOperation, // command: 'tasks.list'
|
|
32
|
+
* flags: { limit: { short: 'l' } },
|
|
33
|
+
* formatHuman: (tasks: Task[]): string => tasks.map((task: Task): string => task.title).join('\n'),
|
|
34
|
+
* });
|
|
35
|
+
* const commander: typeof Commander = await DyCLI_Commander_Util.load();
|
|
36
|
+
*
|
|
37
|
+
* program.addCommand(listTasks.buildCommand(commander, async (values: DyCLI_CommandValues): Promise<void> => {
|
|
38
|
+
* await runner.run(listTasks, values); // `--project-id p-1 -l 5` → { projectId: 'p-1', limit: 5 }
|
|
39
|
+
* }));
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
class DyCLI_Command_Params {
|
|
43
|
+
/** The command name; default: the operation name (`<domain>.<action>`). */
|
|
44
|
+
command;
|
|
45
|
+
/** The help description; default: the operation description. */
|
|
46
|
+
description;
|
|
47
|
+
/** Alternative command names. */
|
|
48
|
+
aliases;
|
|
49
|
+
/** Extra help text shown after the options (examples). */
|
|
50
|
+
helpText;
|
|
51
|
+
/** The server operation the command calls; absent for a local command. */
|
|
52
|
+
operation;
|
|
53
|
+
/** The resolved flags, in schema order, then the extra flags. */
|
|
54
|
+
flags;
|
|
55
|
+
/** The output of this command; absent = `cli_settings.output`, then `json`. */
|
|
56
|
+
output;
|
|
57
|
+
/** Exit-code overrides of this command. */
|
|
58
|
+
exitCodes;
|
|
59
|
+
/** Where the params were constructed (for error diagnostics). */
|
|
60
|
+
stackLocation;
|
|
61
|
+
/**
|
|
62
|
+
* @param set - the command settings; throws a coded `DyFM_Error` (500 `DyNTS-CLP-*`) when invalid
|
|
63
|
+
*/
|
|
64
|
+
constructor(set) {
|
|
65
|
+
const stackLocation = set?.stackLocation ?? (0, fsm_dynamo_1.DyFM_getConstructionStackLocation)();
|
|
66
|
+
const invalid = (code, reason) => DyCLI_Command_Params.invalid(code, `${reason} (command "${set?.command ?? set?.operation?.name}")`, stackLocation);
|
|
67
|
+
const operation = set?.operation;
|
|
68
|
+
// a plain object would skip the construction-time validation of the operation
|
|
69
|
+
if (operation !== undefined && (typeof operation?.name !== 'string' || !operation?.expose)) {
|
|
70
|
+
throw invalid('DyNTS-CLP-OPR', 'operation must be a constructed DyFM_Operation_Settings');
|
|
71
|
+
}
|
|
72
|
+
if (operation?.expose.cli === false) {
|
|
73
|
+
throw invalid('DyNTS-CLP-EXP', `operation "${operation.name}" is not exposed on the CLI (expose.cli: false)`);
|
|
74
|
+
}
|
|
75
|
+
['action', 'formatHuman', 'before', 'after'].forEach((name) => {
|
|
76
|
+
if (set?.[name] !== undefined && typeof set[name] !== 'function') {
|
|
77
|
+
throw invalid('DyNTS-CLP-HOK', `${name} must be a function`);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
if (!operation && !set?.action) {
|
|
81
|
+
throw invalid('DyNTS-CLP-ACT', 'a command needs an operation to call or an own action');
|
|
82
|
+
}
|
|
83
|
+
const command = set.command ?? operation?.name;
|
|
84
|
+
if (typeof command !== 'string' || !DyCLI_commandName.test(command)) {
|
|
85
|
+
throw invalid('DyNTS-CLP-CMD', `command name must be 1-64 letters, digits, ".", "_" or "-" (got: ${JSON.stringify(command)})`);
|
|
86
|
+
}
|
|
87
|
+
const description = set.description ?? operation?.description;
|
|
88
|
+
if (typeof description !== 'string' || !description.trim()) {
|
|
89
|
+
throw invalid('DyNTS-CLP-DSC', 'a command needs a description');
|
|
90
|
+
}
|
|
91
|
+
const aliases = set.aliases ?? [];
|
|
92
|
+
if (!Array.isArray(aliases) || aliases.some((alias) => typeof alias !== 'string' || !DyCLI_commandName.test(alias) || alias === command)) {
|
|
93
|
+
throw invalid('DyNTS-CLP-ALS', 'aliases must be valid command names, different from the command');
|
|
94
|
+
}
|
|
95
|
+
if (set.output !== undefined && !Object.values(cli_output_type_enum_1.DyCLI_Output_Type).includes(set.output)) {
|
|
96
|
+
throw invalid('DyNTS-CLP-OUT', `unknown output ${JSON.stringify(set.output)}`);
|
|
97
|
+
}
|
|
98
|
+
DyCLI_Command_Params.checkExitCodes(set.exitCodes, invalid);
|
|
99
|
+
this.command = command;
|
|
100
|
+
this.description = description;
|
|
101
|
+
this.aliases = [...aliases];
|
|
102
|
+
this.helpText = set.helpText;
|
|
103
|
+
this.operation = operation;
|
|
104
|
+
this.flags = cli_flag_util_1.DyCLI_Flag_Util.resolveFlags(operation, set.flags ?? {}, invalid);
|
|
105
|
+
this.output = set.output;
|
|
106
|
+
this.exitCodes = { ...set.exitCodes };
|
|
107
|
+
this.stackLocation = stackLocation;
|
|
108
|
+
if (set.action) {
|
|
109
|
+
this.action = set.action;
|
|
110
|
+
}
|
|
111
|
+
if (set.formatHuman) {
|
|
112
|
+
this.formatHuman = set.formatHuman;
|
|
113
|
+
}
|
|
114
|
+
if (set.before) {
|
|
115
|
+
this.before = set.before;
|
|
116
|
+
}
|
|
117
|
+
if (set.after) {
|
|
118
|
+
this.after = set.after;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Builds the commander command: name, description, aliases, help text and one option per flag; the action collects
|
|
123
|
+
* the typed values and hands them to `onAction`. A value that does not convert is a commander usage error.
|
|
124
|
+
* @param commander - the module from `DyCLI_Commander_Util.load()`
|
|
125
|
+
* @param onAction - receives the collected values
|
|
126
|
+
*/
|
|
127
|
+
buildCommand(commander, onAction) {
|
|
128
|
+
const command = new commander.Command(this.command).description(this.description);
|
|
129
|
+
this.aliases.forEach((alias) => {
|
|
130
|
+
command.alias(alias);
|
|
131
|
+
});
|
|
132
|
+
if (this.helpText) {
|
|
133
|
+
command.addHelpText('after', this.helpText);
|
|
134
|
+
}
|
|
135
|
+
this.flags.forEach((flag) => {
|
|
136
|
+
command.addOption(DyCLI_Command_Params.optionOf(commander, flag));
|
|
137
|
+
});
|
|
138
|
+
command.action(async (options) => {
|
|
139
|
+
await onAction(this.readValues(options));
|
|
140
|
+
});
|
|
141
|
+
return command;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The values of a call from the parsed commander options: keyed by parameter name, defaults applied, absent flags
|
|
145
|
+
* left out.
|
|
146
|
+
* @param options - the parsed options (`command.opts()`)
|
|
147
|
+
*/
|
|
148
|
+
readValues(options) {
|
|
149
|
+
const values = {};
|
|
150
|
+
this.flags.forEach((flag) => {
|
|
151
|
+
const value = options?.[cli_flag_util_1.DyCLI_Flag_Util.attributeOf(flag.flag)] ?? flag.default;
|
|
152
|
+
if (value !== undefined) {
|
|
153
|
+
values[flag.param] = value;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return values;
|
|
157
|
+
}
|
|
158
|
+
/** The output of this command: its own, then `cli_settings.output`, then `json`. */
|
|
159
|
+
getOutput(settings = global_settings_const_1.DyNTS_global_settings.cli_settings) {
|
|
160
|
+
return this.output ?? settings?.output ?? cli_output_type_enum_1.DyCLI_Output_Type.json;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The process exit code of a failure: a commander parse error or 400/404/422 → usage · 401/403 → auth · an
|
|
164
|
+
* unreachable server → network · any other status → remote · no status → operation error. The command's
|
|
165
|
+
* `exitCodes` win over `cli_settings.exitCodes`, which win over `DyCLI_ExitCode_Type`.
|
|
166
|
+
* @param error - the failure
|
|
167
|
+
* @param settings - the CLI settings (default: `DyNTS_global_settings.cli_settings`)
|
|
168
|
+
*/
|
|
169
|
+
exitCodeOf(error, settings = global_settings_const_1.DyNTS_global_settings.cli_settings) {
|
|
170
|
+
const codes = {
|
|
171
|
+
operationError: cli_exit_code_type_enum_1.DyCLI_ExitCode_Type.operationError, usage: cli_exit_code_type_enum_1.DyCLI_ExitCode_Type.usage,
|
|
172
|
+
auth: cli_exit_code_type_enum_1.DyCLI_ExitCode_Type.auth, network: cli_exit_code_type_enum_1.DyCLI_ExitCode_Type.network, remote: cli_exit_code_type_enum_1.DyCLI_ExitCode_Type.remote,
|
|
173
|
+
...settings?.exitCodes, ...this.exitCodes,
|
|
174
|
+
};
|
|
175
|
+
const failure = (error ?? {});
|
|
176
|
+
const status = failure.___status ?? failure.status;
|
|
177
|
+
if (typeof failure.code === 'string' && failure.code.startsWith('commander.')) {
|
|
178
|
+
return codes.usage;
|
|
179
|
+
}
|
|
180
|
+
if (DyCLI_networkCodes.includes(String(failure.code)) || DyCLI_networkCodes.includes(String(failure.cause?.code))) {
|
|
181
|
+
return codes.network;
|
|
182
|
+
}
|
|
183
|
+
if (typeof status !== 'number') {
|
|
184
|
+
return codes.operationError;
|
|
185
|
+
}
|
|
186
|
+
if (status === 401 || status === 403) {
|
|
187
|
+
return codes.auth;
|
|
188
|
+
}
|
|
189
|
+
if (status === 400 || status === 404 || status === 422) {
|
|
190
|
+
return codes.usage;
|
|
191
|
+
}
|
|
192
|
+
return status >= 400 ? codes.remote : codes.operationError;
|
|
193
|
+
}
|
|
194
|
+
/** Builds the commander option of a flag. */
|
|
195
|
+
static optionOf(commander, flag) {
|
|
196
|
+
const isSwitch = flag.type === cli_flag_value_type_enum_1.DyCLI_FlagValue_Type.boolean;
|
|
197
|
+
const long = isSwitch && flag.default === true ? `--no-${flag.flag}` : `--${flag.flag}`;
|
|
198
|
+
const value = isSwitch ? '' : ` <${flag.type === cli_flag_value_type_enum_1.DyCLI_FlagValue_Type.list ? 'item' : 'value'}>`;
|
|
199
|
+
const option = new commander.Option(`${flag.short ? `-${flag.short}, ` : ''}${long}${value}`, flag.description);
|
|
200
|
+
if (!isSwitch) {
|
|
201
|
+
option.argParser((raw, previous) => {
|
|
202
|
+
try {
|
|
203
|
+
const converted = cli_flag_util_1.DyCLI_Flag_Util.convert(flag, raw);
|
|
204
|
+
return flag.type === cli_flag_value_type_enum_1.DyCLI_FlagValue_Type.list ?
|
|
205
|
+
[...(Array.isArray(previous) ? previous : []), converted] : converted;
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
throw new commander.InvalidArgumentError(error.__userMessage ?? error.message);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (flag.required && !isSwitch) {
|
|
213
|
+
option.makeOptionMandatory(true);
|
|
214
|
+
}
|
|
215
|
+
return option;
|
|
216
|
+
}
|
|
217
|
+
/** Validates the exit-code overrides: integers between 1 and 255 of known outcomes. */
|
|
218
|
+
static checkExitCodes(exitCodes, invalid) {
|
|
219
|
+
const outcomes = ['operationError', 'usage', 'auth', 'network', 'remote'];
|
|
220
|
+
Object.entries(exitCodes ?? {}).forEach(([outcome, code]) => {
|
|
221
|
+
if (!outcomes.includes(outcome) || !Number.isInteger(code) || code < 1 || code > 255) {
|
|
222
|
+
throw invalid('DyNTS-CLP-EXC', `exitCodes.${outcome} must be a known outcome with an integer 1-255`);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
/** Builds the construction error with a stable error code and the construction location. */
|
|
227
|
+
static invalid(code, reason, stackLocation) {
|
|
228
|
+
return new fsm_dynamo_1.DyFM_Error({
|
|
229
|
+
status: 500,
|
|
230
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|${code}`,
|
|
231
|
+
message: `DyCLI_Command_Params construction failed: ${reason}`,
|
|
232
|
+
additionalContent: { stackLocation: stackLocation },
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.DyCLI_Command_Params = DyCLI_Command_Params;
|
|
237
|
+
//# sourceMappingURL=cli-command-params.control-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-command-params.control-model.js","sourceRoot":"","sources":["../../../../../src/_modules/cli/_models/control-models/cli-command-params.control-model.ts"],"names":[],"mappings":";;;AAIA,sDAA+G;AAE/G,0FAAuF;AACvF,oEAAmE;AACnE,kFAA2E;AAC3E,oFAA6E;AAC7E,4EAAsE;AAMtE,qHAAqH;AACrH,MAAM,iBAAiB,GAAW,mCAAmC,CAAC;AACtE,uDAAuD;AACvD,MAAM,kBAAkB,GAAa;IACnC,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,yBAAyB,EAAE,gBAAgB;CACjH,CAAC;AAKF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,oBAAoB;IAC/B,2EAA2E;IAClE,OAAO,CAAS;IACzB,gEAAgE;IACvD,WAAW,CAAS;IAC7B,iCAAiC;IACxB,OAAO,CAAW;IAC3B,0DAA0D;IACjD,QAAQ,CAAU;IAC3B,0EAA0E;IACjE,SAAS,CAAwD;IAC1E,iEAAiE;IACxD,KAAK,CAAe;IAC7B,+EAA+E;IACtE,MAAM,CAAqB;IACpC,2CAA2C;IAClC,SAAS,CAA2B;IAC7C,iEAAiE;IACxD,aAAa,CAAS;IAW/B;;OAEG;IACH,YAAY,GAcX;QACC,MAAM,aAAa,GAAW,GAAG,EAAE,aAAa,IAAI,IAAA,8CAAiC,GAAE,CAAC;QACxF,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,MAAc,EAAc,EAAE,CAC3D,oBAAoB,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,MAAM,cAAc,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,aAAa,CAAC,CAAC;QACrH,MAAM,SAAS,GAAqE,GAAG,EAAE,SAAS,CAAC;QAEnG,8EAA8E;QAC9E,IAAI,SAA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AAM,QAAQ,GAAa,CAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAE,CAAC;QAEtF,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAE,OAAO,EAAE,IAAI,CAAqB,EAAQ,EAAE;YACrF,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAK,IAAe,GAAG,CAAC,IAAK,IAAe,GAAG,GAAG,EAAE,CAAC;gBAC7G,MAAM,OAAO,CAAC,eAAe,EAAE,aAAa,OAAO,gDAAgD,CAAC,CAAC;YACvG,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,4FAA4F;IACpF,MAAM,CAAC,OAAO,CAAC,IAAY,EAAE,MAAc,EAAE,aAAqB;QACxE,OAAO,IAAI,uBAAU,CAAC;YACpB,MAAM,EAAE,GAAG;YACX,SAAS,EAAE,GAAG,6CAAqB,CAAC,mBAAmB,IAAI,IAAI,EAAE;YACjE,OAAO,EAAE,6CAA6C,MAAM,EAAE;YAC9D,iBAAiB,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE;SACpD,CAAC,CAAC;IACL,CAAC;CACF;AA9QD,oDA8QC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The common options every command of a `DyCLI_Program_ControlService` gets (HP-DOPL MP-4.3): `--json --pretty --dry-run`
|
|
3
|
+
* always, `--api-key --base-url --timeout` on commands that call a server operation. A command flag with the same name
|
|
4
|
+
* wins — e.g. the `dryRun` guardrail argument of an operation is a value of the call, not a common option.
|
|
5
|
+
*/
|
|
6
|
+
export interface DyCLI_CommonOptions {
|
|
7
|
+
/** Force the JSON envelope, whatever the command's output. */
|
|
8
|
+
json?: boolean;
|
|
9
|
+
/** Indent the JSON envelope. */
|
|
10
|
+
pretty?: boolean;
|
|
11
|
+
/** Validate and preview without saving (when the command has no own `--dry-run`). */
|
|
12
|
+
dryRun?: boolean;
|
|
13
|
+
/** The API key of the server call. */
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
/** The server base URL. */
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
/** The server call timeout in milliseconds. */
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=cli-common-options.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-common-options.interface.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/cli/_models/interfaces/cli-common-options.interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,8DAA8D;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gCAAgC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qFAAqF;IACrF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-common-options.interface.js","sourceRoot":"","sources":["../../../../../src/_modules/cli/_models/interfaces/cli-common-options.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** The error part of a failed command envelope (HP-DOPL MP-4.3). */
|
|
2
|
+
export interface DyCLI_EnvelopeError {
|
|
3
|
+
/** A stable error code (e.g. `NIT|DyNTS-CLP-VAL`, `INVALID_ARGS`). */
|
|
4
|
+
code: string;
|
|
5
|
+
/** What went wrong, for the caller. */
|
|
6
|
+
message: string;
|
|
7
|
+
/** What the caller can do next, when known. */
|
|
8
|
+
nextStep?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The result envelope of every Dynamo CLI command (HP-DOPL MP-4.3) — the organizer `fo` shape, which the fleet CLIs
|
|
12
|
+
* copy: `{ ok, action, requestId, elapsedMs, result | error }`. Success goes to stdout, failure to stderr.
|
|
13
|
+
*/
|
|
14
|
+
export interface DyCLI_Envelope {
|
|
15
|
+
/** Whether the command succeeded. */
|
|
16
|
+
ok: boolean;
|
|
17
|
+
/** The command name (`cli.parse` for an argument error). */
|
|
18
|
+
action: string;
|
|
19
|
+
/** A unique id of this call. */
|
|
20
|
+
requestId: string;
|
|
21
|
+
/** The run time of the command in milliseconds. */
|
|
22
|
+
elapsedMs: number;
|
|
23
|
+
/** The result of a successful command. */
|
|
24
|
+
result?: unknown;
|
|
25
|
+
/** The error of a failed command. */
|
|
26
|
+
error?: DyCLI_EnvelopeError;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=cli-envelope.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-envelope.interface.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/cli/_models/interfaces/cli-envelope.interface.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,EAAE,EAAE,OAAO,CAAC;IACZ,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,KAAK,CAAC,EAAE,mBAAmB,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-envelope.interface.js","sourceRoot":"","sources":["../../../../../src/_modules/cli/_models/interfaces/cli-envelope.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DyCLI_FlagValue_Type } from '../../_enums/cli-flag-value.type-enum';
|
|
2
|
+
/**
|
|
3
|
+
* The per-parameter flag settings of a command (HP-DOPL MP-4.2): an override of a flag generated from the operation's
|
|
4
|
+
* input schema, or an extra flag the operation does not have. Every field is optional for an override.
|
|
5
|
+
*/
|
|
6
|
+
export interface DyCLI_Flag_Settings {
|
|
7
|
+
/** The long flag without dashes (kebab-case); default: the parameter name in kebab-case (`noteId` → `note-id`). */
|
|
8
|
+
flag?: string;
|
|
9
|
+
/** A one-letter short flag (`l` → `-l`). */
|
|
10
|
+
short?: string;
|
|
11
|
+
/** The help text; default: the schema description. */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** The value kind; default: from the schema type (required for an extra flag). */
|
|
14
|
+
type?: DyCLI_FlagValue_Type;
|
|
15
|
+
/** Allowed values. */
|
|
16
|
+
enum?: (string | number)[];
|
|
17
|
+
/** Whether the flag must be given. */
|
|
18
|
+
required?: boolean;
|
|
19
|
+
/** The value when the flag is not given. */
|
|
20
|
+
default?: unknown;
|
|
21
|
+
/** A custom converter of the raw text; runs instead of the built-in conversion of `type`. */
|
|
22
|
+
parse?(raw: string): unknown;
|
|
23
|
+
}
|
|
24
|
+
/** A resolved flag of a command — what `DyCLI_Command_Params.flags` holds (HP-DOPL MP-4.2). */
|
|
25
|
+
export interface DyCLI_Flag {
|
|
26
|
+
/** The value name (the operation input / body property / guardrail argument name, e.g. `noteId`). */
|
|
27
|
+
param: string;
|
|
28
|
+
/** The long flag without dashes (e.g. `note-id`). */
|
|
29
|
+
flag: string;
|
|
30
|
+
/** The one-letter short flag. */
|
|
31
|
+
short?: string;
|
|
32
|
+
/** The help text. */
|
|
33
|
+
description: string;
|
|
34
|
+
/** The value kind. */
|
|
35
|
+
type: DyCLI_FlagValue_Type;
|
|
36
|
+
/** The kind of one item of a `list` flag (`string` or `number`). */
|
|
37
|
+
itemType?: DyCLI_FlagValue_Type;
|
|
38
|
+
/** Allowed values. */
|
|
39
|
+
enum?: (string | number)[];
|
|
40
|
+
/** Whether the flag must be given. */
|
|
41
|
+
required: boolean;
|
|
42
|
+
/** The value when the flag is not given. */
|
|
43
|
+
default?: unknown;
|
|
44
|
+
/** A custom converter of the raw text. */
|
|
45
|
+
parse?(raw: string): unknown;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=cli-flag.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-flag.interface.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/cli/_models/interfaces/cli-flag.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAG7E;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,mHAAmH;IACnH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,sBAAsB;IACtB,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3B,sCAAsC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6FAA6F;IAC7F,KAAK,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAED,+FAA+F;AAC/F,MAAM,WAAW,UAAU;IACzB,qGAAqG;IACrG,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,sBAAsB;IACtB,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3B,sCAAsC;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,KAAK,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-flag.interface.js","sourceRoot":"","sources":["../../../../../src/_modules/cli/_models/interfaces/cli-flag.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DyCLI_Output_Type } from '../../_enums/cli-output.type-enum';
|
|
2
|
+
/** The exit codes of the command outcomes (HP-DOPL MP-4.2); every value is an integer between 1 and 255. */
|
|
3
|
+
export interface DyCLI_ExitCodes {
|
|
4
|
+
/** A local error without a status (default `1`). */
|
|
5
|
+
operationError: number;
|
|
6
|
+
/** Invalid arguments (default `2`). */
|
|
7
|
+
usage: number;
|
|
8
|
+
/** 401/403 (default `10`). */
|
|
9
|
+
auth: number;
|
|
10
|
+
/** The server could not be reached (default `11`). */
|
|
11
|
+
network: number;
|
|
12
|
+
/** Any other error status (default `12`). */
|
|
13
|
+
remote: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* CLI-wide defaults (`DyNTS_global_settings.cli_settings`, HP-DOPL MP-4.2). `null` (the default) means every field below
|
|
17
|
+
* takes its documented default; a command's own settings win.
|
|
18
|
+
*/
|
|
19
|
+
export interface DyCLI_Settings {
|
|
20
|
+
/** The default output of the commands; default: `json`. */
|
|
21
|
+
output?: DyCLI_Output_Type;
|
|
22
|
+
/** Exit-code overrides; default: `DyCLI_ExitCode_Type`. */
|
|
23
|
+
exitCodes?: Partial<DyCLI_ExitCodes>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=cli-settings.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-settings.interface.d.ts","sourceRoot":"","sources":["../../../../../src/_modules/cli/_models/interfaces/cli-settings.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAGtE,4GAA4G;AAC5G,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,cAAc,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-settings.interface.js","sourceRoot":"","sources":["../../../../../src/_modules/cli/_models/interfaces/cli-settings.interface.ts"],"names":[],"mappings":""}
|