@bemoje/cli 0.0.2 → 0.0.3
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/index.cjs.js +2338 -1764
- package/index.esm.js +2243 -1659
- package/package.json +5 -3
- package/src/{core/CommandBuilder → arg}/ArgumentBuilder.d.ts +5 -6
- package/src/arg/ArgumentParserSelector.d.ts +8 -0
- package/src/{core/CommandBuilder → arg}/ArgumentReader.d.ts +1 -2
- package/src/arg/ArgumentValidatorSelector.d.ts +7 -0
- package/src/cmd/CLI.d.ts +2 -0
- package/src/cmd/CommandBuilder.d.ts +238 -0
- package/src/cmd/CommandBuilderMetaData.d.ts +23 -0
- package/src/cmd/CommandFeatureSelector.d.ts +79 -0
- package/src/cmd/DefaultHelpConfig.d.ts +2 -0
- package/src/core/OutputManager.d.ts +63 -0
- package/src/{parsers/selector/AbstractStringParserSelector.d.ts → core/ParserSelector.d.ts} +5 -6
- package/src/core/ValidatorSelector.d.ts +16 -0
- package/src/core/counter.d.ts +3 -0
- package/src/db/AbstractJsonFileSection.d.ts +136 -0
- package/src/db/AppDataSection.d.ts +29 -0
- package/src/db/ConfigSection.d.ts +47 -0
- package/src/db/JsonFile.d.ts +35 -0
- package/src/db/PresetsSection.d.ts +44 -0
- package/src/index.d.ts +102 -112
- package/src/opt/OptionArgumentParserSelector.d.ts +7 -0
- package/src/opt/OptionArgumentValidatorSelector.d.ts +7 -0
- package/src/{core/CommandBuilder → opt}/OptionBuilder.d.ts +6 -5
- package/src/opt/OptionHelpers.d.ts +32 -0
- package/src/{core/CommandBuilder → opt}/OptionReader.d.ts +2 -3
- package/src/proto/overrideCommanderPrototype.d.ts +8 -0
- package/src/types/IConfig.d.ts +21 -0
- package/src/types/IPreset.d.ts +6 -7
- package/src/util/array/arrLast.d.ts +12 -0
- package/src/util/array/arrSome.d.ts +15 -0
- package/src/util/array/types/ArrayPredicate.d.ts +10 -0
- package/src/util/db/JsonDB.d.ts +65 -0
- package/src/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.d.ts +15 -0
- package/src/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.d.ts +9 -0
- package/src/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.d.ts +13 -0
- package/src/util/fs/readFile/readFileSafeSync.d.ts +13 -0
- package/src/util/fs/readFile/readFileSync.d.ts +10 -0
- package/src/util/fs/readJsonFile/readJsonFileSafeSync.d.ts +9 -0
- package/src/util/fs/removeFile/removeFile.d.ts +1 -0
- package/src/util/fs/tempFile/tempFileSync.d.ts +7 -0
- package/src/util/fs/types/IReadJsonFileOptions.d.ts +1 -0
- package/src/util/fs/writeFile/writeFileSafeSync.d.ts +1 -0
- package/src/util/fs/writeFile/writeFileSync.d.ts +1 -0
- package/src/util/fs/writeJsonFile/writeJsonFileSafe.d.ts +1 -0
- package/src/{core/util → util/function}/MethodDisabler.d.ts +4 -3
- package/src/util/function/funSetName.d.ts +13 -0
- package/src/util/node/execInherit.d.ts +1 -0
- package/src/{core/util → util/object}/createArrayMerger.d.ts +3 -0
- package/src/{core/util → util/object}/createObjectMerger.d.ts +4 -1
- package/src/util/object/objUpdatePropertyDescriptors.d.ts +16 -0
- package/src/util/object/setNonEnumerable.d.ts +15 -0
- package/src/util/os/defaultOpenInEditorCommand.d.ts +5 -0
- package/src/util/os/isOSX.d.ts +6 -0
- package/src/util/os/isVsCodeInstalled.d.ts +5 -0
- package/src/util/os/isWindows.d.ts +8 -0
- package/src/util/path/getTempDataPath.d.ts +6 -0
- package/src/util/regex/regexEscapeString.d.ts +11 -0
- package/src/util/string/strEnsureStartsWith.d.ts +12 -0
- package/src/util/string/strFirstCharToUpperCase.d.ts +9 -0
- package/src/util/string/strIsLowerCase.d.ts +11 -0
- package/src/util/string/strIsUpperCase.d.ts +11 -0
- package/src/util/string/strSplitCamelCase.d.ts +11 -0
- package/src/util/types/Any.d.ts +1 -0
- package/src/util/types/DeepArray.d.ts +10 -0
- package/src/util/types/DeepObject.d.ts +14 -0
- package/src/util/types/JsonArray.d.ts +6 -0
- package/src/util/types/JsonDefinedPrimitive.d.ts +4 -0
- package/src/util/types/JsonObject.d.ts +6 -0
- package/src/util/types/JsonRawPrimitive.d.ts +5 -0
- package/src/util/types/JsonValue.d.ts +7 -0
- package/src/util/types/ObjectKey.d.ts +1 -0
- package/src/util/types/TConstructor.d.ts +5 -0
- package/src/util/types/TFunction.d.ts +4 -0
- package/src/util/types/TFunctionNoNew.d.ts +2 -0
- package/src/util/types/TPlainObject.d.ts +2 -0
- package/src/util/types/TPrimitive.d.ts +1 -0
- package/src/util/types/TValidator.d.ts +1 -0
- package/src/{validators → util/validation}/createTypedArrayValidator.d.ts +1 -3
- package/src/util/validation/ensureThat.d.ts +6 -0
- package/src/util/validation/isFunction.d.ts +11 -0
- package/src/{validators → util/validation}/isNamedFunction.d.ts +1 -1
- package/src/util/validation/isObject.d.ts +15 -0
- package/src/util/validation/isPlainObject.d.ts +6 -0
- package/src/util/validation/isPrimitive.d.ts +12 -0
- package/src/util/validation/numbers/isInteger.d.ts +13 -0
- package/src/util/validation/numbers/isValidNumber.d.ts +15 -0
- package/src/core/CommandBuilder/Base.d.ts +0 -5
- package/src/core/CommandBuilder/CommandBuilder.d.ts +0 -80
- package/src/core/CommandBuilder/CommandBuilder.example.d.ts +0 -1
- package/src/core/CommandBuilder/CommandBuilderMetaData.d.ts +0 -17
- package/src/core/CommandBuilder/CommandFeatureSelector.d.ts +0 -26
- package/src/core/CommandBuilder/OutputManager.d.ts +0 -47
- package/src/core/CommandBuilder/assertCommandNameNotReserved.d.ts +0 -1
- package/src/core/CommandBuilder/ensureBackRefToCommandBuilder.d.ts +0 -7
- package/src/core/CommandBuilder/features/action/actionWrapper.d.ts +0 -5
- package/src/core/CommandBuilder/features/action/combineVariadicArgs.d.ts +0 -3
- package/src/core/CommandBuilder/features/action/debugLogArgsOpts.d.ts +0 -4
- package/src/core/CommandBuilder/features/action/deleteOptionsWithDefaultOrNoValue.d.ts +0 -3
- package/src/core/CommandBuilder/features/action/getPresetArgsAndOpts.d.ts +0 -3
- package/src/core/CommandBuilder/features/action/handleError.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/handleOutputOptions.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/optsWithGlobalsParsed.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/padArgsWithUndefinedUntilExpectedLength.d.ts +0 -3
- package/src/core/CommandBuilder/features/action/parseArguments.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/parseOptions.d.ts +0 -6
- package/src/core/CommandBuilder/features/action/parsedValidArgsOptsWithPresets.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/parsedValidArgsWithPresets.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/parsedValidOptsWithPresets.d.ts +0 -3
- package/src/core/CommandBuilder/features/addConfigCommands.d.ts +0 -3
- package/src/core/CommandBuilder/features/addPresetsCommands.d.ts +0 -3
- package/src/core/CommandBuilder/features/addUtilCommands.d.ts +0 -2
- package/src/core/CommandBuilder/features/assertNoDuplicateCommandNames.d.ts +0 -2
- package/src/core/CommandBuilder/features/assertNoDuplicateOptionNames.d.ts +0 -2
- package/src/core/CommandBuilder/features/autoAssignMissingOptionFlags.d.ts +0 -14
- package/src/core/CommandBuilder/features/autoAssignSubCommandAliases.d.ts +0 -13
- package/src/core/CommandBuilder/features/getClosestNonNativeParent.d.ts +0 -2
- package/src/core/CommandBuilder/getGlobalOptions.d.ts +0 -3
- package/src/core/CommandBuilder/getOwnAndGlobalOptions.d.ts +0 -3
- package/src/core/CommandBuilder/initializeCommand.d.ts +0 -2
- package/src/core/db/AbstractJsonFileSection.d.ts +0 -45
- package/src/core/db/ConfigSection.d.ts +0 -19
- package/src/core/db/JsonDB.d.ts +0 -19
- package/src/core/db/JsonFile.d.ts +0 -25
- package/src/core/db/JsonFileError.d.ts +0 -6
- package/src/core/db/PresetsSection.d.ts +0 -14
- package/src/core/help/configureHelp.d.ts +0 -2
- package/src/core/util/assertPresetArgsOptional.d.ts +0 -3
- package/src/core/util/assertValidArguments.d.ts +0 -6
- package/src/core/util/assertValidOptions.d.ts +0 -6
- package/src/core/util/assertValidPreset.d.ts +0 -3
- package/src/core/util/commandExists.d.ts +0 -5
- package/src/core/util/commandLocation.d.ts +0 -5
- package/src/core/util/errorToString.d.ts +0 -1
- package/src/core/util/escapeShellCommandArgument.d.ts +0 -5
- package/src/core/util/forEachChildRecursive.d.ts +0 -4
- package/src/core/util/getARGV.d.ts +0 -1
- package/src/core/util/getAncestors.d.ts +0 -7
- package/src/core/util/getChildren.d.ts +0 -4
- package/src/core/util/getJsonFilepath.d.ts +0 -2
- package/src/core/util/getOptionArgumentName.d.ts +0 -5
- package/src/core/util/getRootCommand.d.ts +0 -5
- package/src/core/util/getSiblings.d.ts +0 -5
- package/src/core/util/hasVariadicArguments.d.ts +0 -5
- package/src/core/util/objDestroy.d.ts +0 -2
- package/src/core/util/optHasArgument.d.ts +0 -2
- package/src/core/util/prefixArray.d.ts +0 -5
- package/src/core/util/prefixString.d.ts +0 -5
- package/src/core/util/prefixStringsRecursive.d.ts +0 -5
- package/src/core/util/renderOptionFlags.d.ts +0 -6
- package/src/core/util/setOptionLongName.d.ts +0 -6
- package/src/core/util/setOptionShortName.d.ts +0 -6
- package/src/core/util/walkAncestors.d.ts +0 -7
- package/src/core/util/walkChildren.d.ts +0 -4
- package/src/core/util/walkSiblings.d.ts +0 -5
- package/src/parsers/createTupleListParser.d.ts +0 -11
- package/src/parsers/selector/ArgumentParserSelector.d.ts +0 -7
- package/src/parsers/selector/OptionArgumentParserSelector.d.ts +0 -7
- package/src/types/IDefinePropertyOptions.d.ts +0 -9
- package/src/types/IPresets.d.ts +0 -6
- package/src/types/TValidator.d.ts +0 -2
- package/src/validators/createLengthValidator.d.ts +0 -7
- package/src/validators/isInteger.d.ts +0 -1
- package/src/validators/isIntegerArray.d.ts +0 -4
- package/src/validators/isNull.d.ts +0 -1
- package/src/validators/isNumber.d.ts +0 -1
- package/src/validators/isNumberArray.d.ts +0 -4
- package/src/validators/isNumericString.d.ts +0 -1
- package/src/validators/selector/ArgumentValidatorSelector.d.ts +0 -6
- package/src/validators/selector/OptionArgumentValidatorSelector.d.ts +0 -6
- package/src/validators/selector/ValidatorSelector.d.ts +0 -17
- /package/src/core/{util/splitCombinedArgvShorts.d.ts → splitCombinedArgvShorts.d.ts} +0 -0
- /package/src/{core/CommandBuilder → util/errors}/ErrorParser.d.ts +0 -0
- /package/src/{core/CommandBuilder/features → util/node}/formatTableForTerminal.d.ts +0 -0
- /package/src/{core/util → util/object}/arrAssign.d.ts +0 -0
- /package/src/{core/util → util/object}/objAssign.d.ts +0 -0
- /package/src/{core/util → util/object}/realizeLazyProperty.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/createBooleanParser.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/createTypedListParser.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/parseBoolean.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/parseInteger.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/parseNumber.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/parseString.d.ts +0 -0
- /package/src/{types → util/types}/TStringParser.d.ts +0 -0
- /package/src/{validators → util/validation}/isArray.d.ts +0 -0
- /package/src/{validators → util/validation}/isBoolean.d.ts +0 -0
- /package/src/{validators → util/validation}/isNamedFunctionArray.d.ts +0 -0
- /package/src/{validators → util/validation}/isString.d.ts +0 -0
- /package/src/{validators → util/validation}/isStringArray.d.ts +0 -0
- /package/src/{validators → util/validation}/isStringWithNoSpacesOrDashes.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"
|
|
5
|
+
"ansi-colors": "^4.1.3",
|
|
6
6
|
"cli-table": "^0.3.11",
|
|
7
7
|
"commander": "^11.1.0",
|
|
8
|
-
"
|
|
8
|
+
"fs-extra": "^11.2.0",
|
|
9
|
+
"is-async-function": "^2.0.0"
|
|
9
10
|
},
|
|
10
11
|
"type": "commonjs",
|
|
11
12
|
"main": "./index.cjs.js",
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"homepage": "https://github.com/bemoje/tsmono",
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/cli-table": "^0.3.4",
|
|
35
|
+
"@types/is-async-function": "^2.0.2",
|
|
34
36
|
"@types/prompts": "^2.4.9"
|
|
35
37
|
}
|
|
36
38
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Argument } from 'commander';
|
|
2
|
-
import { ArgumentParserSelector } from '
|
|
2
|
+
import { ArgumentParserSelector } from './ArgumentParserSelector';
|
|
3
3
|
import { ArgumentReader } from './ArgumentReader';
|
|
4
|
-
import { ArgumentValidatorSelector } from '
|
|
5
|
-
import {
|
|
6
|
-
import { CommandBuilder } from './CommandBuilder';
|
|
4
|
+
import { ArgumentValidatorSelector } from './ArgumentValidatorSelector';
|
|
5
|
+
import { CommandBuilder } from '../cmd/CommandBuilder';
|
|
7
6
|
/**
|
|
8
|
-
* Wrapper around the @see Argument class
|
|
7
|
+
* Wrapper around the @see Argument class from 'commander'.
|
|
9
8
|
*/
|
|
10
|
-
export declare class ArgumentBuilder
|
|
9
|
+
export declare class ArgumentBuilder {
|
|
11
10
|
readonly cmd: CommandBuilder;
|
|
12
11
|
readonly $: Argument;
|
|
13
12
|
readonly index: number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ArgumentBuilder } from './ArgumentBuilder';
|
|
2
|
+
import { JsonValue } from '../util/types/JsonValue';
|
|
3
|
+
import { ParserSelector } from '../core/ParserSelector';
|
|
4
|
+
import { TStringParser } from '../util/types/TStringParser';
|
|
5
|
+
export declare class ArgumentParserSelector extends ParserSelector<ArgumentBuilder> {
|
|
6
|
+
constructor(builder: ArgumentBuilder);
|
|
7
|
+
custom<T extends JsonValue>(parser: TStringParser<T>): ArgumentBuilder;
|
|
8
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ArgumentBuilder } from './ArgumentBuilder';
|
|
2
|
-
|
|
3
|
-
export declare class ArgumentReader extends Base {
|
|
2
|
+
export declare class ArgumentReader {
|
|
4
3
|
protected readonly parent: ArgumentBuilder;
|
|
5
4
|
constructor(parent: ArgumentBuilder);
|
|
6
5
|
get $(): import("commander").Argument;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ArgumentBuilder } from './ArgumentBuilder';
|
|
2
|
+
import { TValidator } from '../util/types/TValidator';
|
|
3
|
+
import { ValidatorSelector } from '../core/ValidatorSelector';
|
|
4
|
+
export declare class ArgumentValidatorSelector extends ValidatorSelector<ArgumentBuilder> {
|
|
5
|
+
constructor(builder: ArgumentBuilder);
|
|
6
|
+
custom<O>(validator: TValidator<O>): ArgumentBuilder;
|
|
7
|
+
}
|
package/src/cmd/CLI.d.ts
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { AddHelpTextPosition, Argument, Command, CommanderError, ErrorOptions, HelpConfiguration, HookEvent, Option, OptionValues, OptionValueSource } from 'commander';
|
|
2
|
+
import { Any } from '../util/types/Any';
|
|
3
|
+
import { ArgumentBuilder } from '../arg/ArgumentBuilder';
|
|
4
|
+
import { CommandBuilderMetaData } from './CommandBuilderMetaData';
|
|
5
|
+
import { CommandFeatureSelector } from './CommandFeatureSelector';
|
|
6
|
+
import { IConfig } from '../types/IConfig';
|
|
7
|
+
import { IPreset, IPresetPartial } from '../types/IPreset';
|
|
8
|
+
import { JsonFile } from '../db/JsonFile';
|
|
9
|
+
import { JsonValue } from '../util/types/JsonValue';
|
|
10
|
+
import { OptionBuilder } from '../opt/OptionBuilder';
|
|
11
|
+
export * from 'commander';
|
|
12
|
+
/**
|
|
13
|
+
* Wrapper around the @see Command class, for more intuitive construction.
|
|
14
|
+
*/
|
|
15
|
+
export declare class CommandBuilder {
|
|
16
|
+
static dataDirectory: string;
|
|
17
|
+
protected readonly features: CommandFeatureSelector;
|
|
18
|
+
readonly parent: CommandBuilder | null;
|
|
19
|
+
readonly $: Command;
|
|
20
|
+
readonly meta: CommandBuilderMetaData;
|
|
21
|
+
get db(): JsonFile;
|
|
22
|
+
constructor(name: string, callback?: (this: CommandBuilder, cmd: CommandBuilder) => void, parent?: CommandBuilder, isNative?: boolean);
|
|
23
|
+
setRecommended(): void;
|
|
24
|
+
deleteDataFile(): void;
|
|
25
|
+
version(string: string): this;
|
|
26
|
+
description(...lines: string[]): this;
|
|
27
|
+
alias(alias: string): this;
|
|
28
|
+
aliases(...aliases: string[]): this;
|
|
29
|
+
enableBuiltinOptions(options?: {
|
|
30
|
+
debug?: boolean;
|
|
31
|
+
disableColor?: boolean;
|
|
32
|
+
disableStderr?: boolean;
|
|
33
|
+
disableStdout?: boolean;
|
|
34
|
+
}): this;
|
|
35
|
+
argument(name: string, description?: string): this;
|
|
36
|
+
argument(name: string, cb: (opt: ArgumentBuilder, cmd: this) => void): this;
|
|
37
|
+
option(flags: string, description?: string): this;
|
|
38
|
+
option(flags: string, cb?: (opt: OptionBuilder, cmd: this) => void): this;
|
|
39
|
+
globalOption(flags: string, description?: string): this;
|
|
40
|
+
globalOption(flags: string, cb?: (opt: OptionBuilder, cmd: this) => void): this;
|
|
41
|
+
command(name: string, cb: (this: CommandBuilder, cmd: CommandBuilder) => void): this;
|
|
42
|
+
nativeCommand(name: string, cb: (this: CommandBuilder, cmd: CommandBuilder) => void): this;
|
|
43
|
+
action<T extends (...args: Any[]) => void | Promise<void>>(fn: T): this;
|
|
44
|
+
errorHandler(fn: (this: Command, error: unknown, cmd: CommandBuilder) => void): this;
|
|
45
|
+
appData(key: string, value: JsonValue): this;
|
|
46
|
+
config(key: string, entry: IConfig<JsonValue>): this;
|
|
47
|
+
preset(name: string, preset: IPresetPartial): this;
|
|
48
|
+
presetsEnabled(boolean?: boolean): this;
|
|
49
|
+
autoAssignMissingOptionFlags(boolean?: boolean): this;
|
|
50
|
+
autoAssignSubCommandAliases(boolean?: boolean): this;
|
|
51
|
+
allowExcessArguments(bool?: boolean): this;
|
|
52
|
+
allowUnknownOption(bool?: boolean): this;
|
|
53
|
+
/**
|
|
54
|
+
* Register callback to use as replacement for calling process.exit.
|
|
55
|
+
*/
|
|
56
|
+
exitOverride(callback?: (err: CommanderError) => never | void): this;
|
|
57
|
+
throwInsteadOfProcessExit(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Add hook for life cycle event.
|
|
60
|
+
*/
|
|
61
|
+
hook(event: HookEvent, listener: (thisCommand: Command, actionCommand: Command) => void | Promise<void>): this;
|
|
62
|
+
/**
|
|
63
|
+
* You can customise the help by overriding Help properties using configureHelp(),
|
|
64
|
+
* or with a subclass of Help by overriding createHelp().
|
|
65
|
+
*/
|
|
66
|
+
configureHelp(configuration: HelpConfiguration): this;
|
|
67
|
+
/**
|
|
68
|
+
* Display the help or a custom message after an error occurs.
|
|
69
|
+
*/
|
|
70
|
+
showHelpAfterError(displayHelp?: boolean | string): this;
|
|
71
|
+
/**
|
|
72
|
+
* Display suggestion of similar commands for unknown commands, or options for unknown options.
|
|
73
|
+
*/
|
|
74
|
+
showSuggestionAfterError(displaySuggestion?: boolean): this;
|
|
75
|
+
/**
|
|
76
|
+
* Add additional text to be displayed with the built-in help.
|
|
77
|
+
*
|
|
78
|
+
* Position is 'before' or 'after' to affect just this command,
|
|
79
|
+
* and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
|
|
80
|
+
*/
|
|
81
|
+
addHelpText(position: AddHelpTextPosition, text: string): this;
|
|
82
|
+
throwCommanderError(message: string, exitCode?: number, type?: string): never;
|
|
83
|
+
hideGlobalOptions(...names: string[]): this;
|
|
84
|
+
unhideGlobalOptions(...names: string[]): this;
|
|
85
|
+
/**
|
|
86
|
+
* Set the directory for searching for executable subcommands of this command.
|
|
87
|
+
*/
|
|
88
|
+
executableDir(path: string): this;
|
|
89
|
+
/**
|
|
90
|
+
* Store option value.
|
|
91
|
+
*/
|
|
92
|
+
setOptionValue(key: string, value: unknown): this;
|
|
93
|
+
/**
|
|
94
|
+
* Store option value and where the value came from.
|
|
95
|
+
*/
|
|
96
|
+
setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this;
|
|
97
|
+
setDataFilepath(filepath: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Display error message and exit (or call exitOverride).
|
|
100
|
+
*/
|
|
101
|
+
outputError(message: string, options?: ErrorOptions): void;
|
|
102
|
+
/**
|
|
103
|
+
* Output help information for this command.
|
|
104
|
+
*/
|
|
105
|
+
outputHelp(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Display error message and exit (or call exitOverride).
|
|
108
|
+
*/
|
|
109
|
+
outputDebugMessage(event: string, getProps?: () => Record<string, unknown>): void;
|
|
110
|
+
parseArguments(args: string[]): any[];
|
|
111
|
+
/**
|
|
112
|
+
* Parses (and validates) options using the parsers defined in the command builder.
|
|
113
|
+
*/
|
|
114
|
+
parseOptions(opts: OptionValues): OptionValues;
|
|
115
|
+
/**
|
|
116
|
+
* Validate ALREADY PARSED args using the validators defined in the command builder.
|
|
117
|
+
*/
|
|
118
|
+
assertValidArguments(parsedArgs: Any[]): any[];
|
|
119
|
+
/**
|
|
120
|
+
* Validate ALREADY PARSED options using the validators defined in the command builder.
|
|
121
|
+
*/
|
|
122
|
+
assertValidOptions(parsedOptions: OptionValues): OptionValues;
|
|
123
|
+
assertValidPreset(key: string, preset: IPreset): void;
|
|
124
|
+
get name(): string;
|
|
125
|
+
/**
|
|
126
|
+
* Get the command at the root of the command tree.
|
|
127
|
+
*/
|
|
128
|
+
get root(): CommandBuilder;
|
|
129
|
+
get isRoot(): boolean;
|
|
130
|
+
get arguments(): readonly Argument[];
|
|
131
|
+
get options(): readonly Option[];
|
|
132
|
+
get commander(): Command;
|
|
133
|
+
get hasGrandChildren(): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Returns whether a command's last argument is variadic.
|
|
136
|
+
*/
|
|
137
|
+
get isLastArgVariadic(): boolean;
|
|
138
|
+
get dataFilepath(): string;
|
|
139
|
+
/**
|
|
140
|
+
* Get the executable search directory.
|
|
141
|
+
*/
|
|
142
|
+
getExecutableDir(): string | null;
|
|
143
|
+
/**
|
|
144
|
+
* Retrieve option value.
|
|
145
|
+
*/
|
|
146
|
+
getOptionValue(key: string): Any;
|
|
147
|
+
/**
|
|
148
|
+
* Get source of option value.
|
|
149
|
+
*/
|
|
150
|
+
getOptionValueSource(key: string): OptionValueSource | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Get source of option value. See also .optsWithGlobals().
|
|
153
|
+
*/
|
|
154
|
+
getOptionValueSourceWithGlobals(key: string): OptionValueSource | undefined;
|
|
155
|
+
getActionHandler(): (this: CommandBuilder, ...args: any[]) => void | Promise<void>;
|
|
156
|
+
getDescription(): string;
|
|
157
|
+
getSummary(): string;
|
|
158
|
+
getVersion(): string | undefined;
|
|
159
|
+
getAlias(): string;
|
|
160
|
+
getAliases(): string[];
|
|
161
|
+
/**
|
|
162
|
+
* Get a commands prefix array based on all its parent/ancestor commands.
|
|
163
|
+
*/
|
|
164
|
+
getPrefixArray(): string[];
|
|
165
|
+
/**
|
|
166
|
+
* Get a commands prefix string based on all its parent/ancestor commands.
|
|
167
|
+
*/
|
|
168
|
+
getPrefixString(): string;
|
|
169
|
+
getGlobalOptions(): Option[];
|
|
170
|
+
getOwnAndGlobalOptions(): Option[];
|
|
171
|
+
getChildrenIterator(options?: {
|
|
172
|
+
includeSelf?: boolean;
|
|
173
|
+
}): Generator<CommandBuilder>;
|
|
174
|
+
getChildren(options?: {
|
|
175
|
+
includeSelf?: boolean;
|
|
176
|
+
}): CommandBuilder[];
|
|
177
|
+
getAncestorsIterator(options?: {
|
|
178
|
+
includeSelf?: boolean;
|
|
179
|
+
}): Generator<CommandBuilder>;
|
|
180
|
+
/**
|
|
181
|
+
* Get a command's ancestors, optionally starting from the command itself.
|
|
182
|
+
*/
|
|
183
|
+
getAncestors(options?: {
|
|
184
|
+
includeSelf?: boolean;
|
|
185
|
+
}): CommandBuilder[];
|
|
186
|
+
getSiblingsIterator(): Generator<CommandBuilder, void, unknown>;
|
|
187
|
+
/**
|
|
188
|
+
* Returns an array of sibling CommandBuilder objects.
|
|
189
|
+
*/
|
|
190
|
+
getSiblings(): CommandBuilder[];
|
|
191
|
+
getClosestNonNativeParent(): CommandBuilder;
|
|
192
|
+
getRenderedHelp(): string;
|
|
193
|
+
getOptsWithGlobalsParsed(): OptionValues;
|
|
194
|
+
getParsedValidArgsOptsWithPresets(): [Any[], OptionValues];
|
|
195
|
+
getParsedValidArgsWithPresets<T>(presetArgs: T[][]): any[];
|
|
196
|
+
getParsedValidOptsWithPresets(presetOpts: OptionValues[]): OptionValues;
|
|
197
|
+
getPresetArgsAndOpts(): [presetArgs: string[][], presetOpts: OptionValues[], presetOrder: string[]];
|
|
198
|
+
protected combineVariadicArgs(result: Any[]): any[];
|
|
199
|
+
protected debugLogArgsOpts(args: Any[], opts: OptionValues, presetArgs: string[][], presetOpts: OptionValues[], presetOrder: string[]): void;
|
|
200
|
+
protected deleteOptionsWithDefaultOrNoValue(opts: OptionValues): OptionValues;
|
|
201
|
+
protected handleOutputOptions(): void;
|
|
202
|
+
protected padArgsWithUndefinedUntilExpectedLength(args: Any[]): any[];
|
|
203
|
+
protected assertPresetArgsOptional(args: Any[]): void;
|
|
204
|
+
protected addUtilCommands(): void;
|
|
205
|
+
/**
|
|
206
|
+
* Makes aliases for the command.
|
|
207
|
+
* The idea is to be able to navigate the command tree by only typing the first letter(s) of the command names.
|
|
208
|
+
*
|
|
209
|
+
* Example: A command 'cola' would get these aliases: ['c', 'co', 'col'].
|
|
210
|
+
* However, if there are namespace clashes with sibling subcommands that start with the same letter,
|
|
211
|
+
* eg. like 'cola' and 'coal' where the first two letters clash, cola's aliases are reduced to only ['col'] and similarly for 'coal'.
|
|
212
|
+
*
|
|
213
|
+
* This method creates the aliases, ensuring there are no clashes with sublings, why it is important that the
|
|
214
|
+
* entire command tree is built before invoking this method.
|
|
215
|
+
*/
|
|
216
|
+
protected assignSubCommandAliases(): this;
|
|
217
|
+
/**
|
|
218
|
+
* Automatically set 'short' and 'long' names to options that don't have one assigned yet.
|
|
219
|
+
*
|
|
220
|
+
* First, it tries to assign a short name based on the first letter of the option's attribute name
|
|
221
|
+
* Both lower and upper case are tried. If these is not available, the next letter of the option name is tried.
|
|
222
|
+
*
|
|
223
|
+
* If none of the letters of the option name are available, the option is skipped until all other
|
|
224
|
+
* options have had letters from their names attempted assigned.
|
|
225
|
+
* Those that remain are assigned the first available letter of the alphabet + 0-9.
|
|
226
|
+
* If there are 64 options for the command and no more alphanumeric characters are available,
|
|
227
|
+
* the option is not assigned a short name.
|
|
228
|
+
*/
|
|
229
|
+
protected assignMissingOptionFlags(): void;
|
|
230
|
+
protected assertNoDuplicateCommandNames(): void;
|
|
231
|
+
protected hasIdenticalParentOption(option: Option): boolean;
|
|
232
|
+
protected assertNoDuplicateOptionNames(): void;
|
|
233
|
+
protected initializeActionWrapper(): void;
|
|
234
|
+
protected initializeHelp(): void;
|
|
235
|
+
protected inheritParentHiddenGlobals(): void;
|
|
236
|
+
protected assertCommandNameNotReserved(name: string): void;
|
|
237
|
+
protected assertNotInitialized(): void;
|
|
238
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Any } from '../util/types/Any';
|
|
2
|
+
import { CommandBuilder } from './CommandBuilder';
|
|
3
|
+
import { Option } from 'commander';
|
|
4
|
+
import { TStringParser } from '../util/types/TStringParser';
|
|
5
|
+
import { TValidator } from '../util/types/TValidator';
|
|
6
|
+
export declare class CommandBuilderMetaData {
|
|
7
|
+
subcommands: CommandBuilder[];
|
|
8
|
+
globalOptions: Option[];
|
|
9
|
+
hiddenGlobalOptions: Set<Option>;
|
|
10
|
+
presetOptionKeys: string[];
|
|
11
|
+
argParsers: TStringParser<Any>[];
|
|
12
|
+
argValidators: TValidator<Any>[][];
|
|
13
|
+
optParsers: Record<string, TStringParser<Any>>;
|
|
14
|
+
optValidators: Record<string, TValidator<Any>[]>;
|
|
15
|
+
rawArgs: string[];
|
|
16
|
+
isNative: boolean;
|
|
17
|
+
isInitialized: boolean;
|
|
18
|
+
constructor();
|
|
19
|
+
get actionHandler(): (this: CommandBuilder, ...args: any[]) => void | Promise<void>;
|
|
20
|
+
get errorHandler(): (this: CommandBuilder, error: unknown, cmd: CommandBuilder) => void;
|
|
21
|
+
get hasCustomActionHandler(): boolean;
|
|
22
|
+
get hasCustomErrorHandler(): boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { CommandBuilder } from './CommandBuilder';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a selector for enabling or disabling command features.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CommandFeatureSelector {
|
|
6
|
+
protected readonly cmd: CommandBuilder;
|
|
7
|
+
/**
|
|
8
|
+
* Indicates whether the app data feature is enabled.
|
|
9
|
+
*/
|
|
10
|
+
isAppDataEnabled: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Indicates whether the config feature is enabled.
|
|
13
|
+
*/
|
|
14
|
+
isConfigEnabled: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Indicates whether the presets feature is enabled.
|
|
17
|
+
*/
|
|
18
|
+
isPresetsEnabled: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Indicates whether the auto assign missing option flags feature is enabled.
|
|
21
|
+
*/
|
|
22
|
+
isAutoAssignMissingOptionFlagsEnabled: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Indicates whether the auto assign sub command aliases feature is enabled.
|
|
25
|
+
*/
|
|
26
|
+
isAutoAssignSubCommandAliasesEnabled: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new instance of the CommandFeatureSelector class.
|
|
29
|
+
* @param cmd - The command builder instance.
|
|
30
|
+
*/
|
|
31
|
+
constructor(cmd: CommandBuilder);
|
|
32
|
+
/**
|
|
33
|
+
* Inherits the feature settings from a parent CommandFeatureSelector instance.
|
|
34
|
+
* @param parentFeatures - The parent CommandFeatureSelector instance to inherit from.
|
|
35
|
+
*/
|
|
36
|
+
inheritFrom(parentFeatures: CommandFeatureSelector): void;
|
|
37
|
+
/**
|
|
38
|
+
* Enables or disables the app data feature.
|
|
39
|
+
* @param boolean - Indicates whether the app data feature should be enabled or disabled.
|
|
40
|
+
* @returns The current CommandFeatureSelector instance.
|
|
41
|
+
* @throws Error if the command is native and the app data feature is being configured.
|
|
42
|
+
*/
|
|
43
|
+
appData(boolean?: boolean): this;
|
|
44
|
+
/**
|
|
45
|
+
* Enables or disables the config feature.
|
|
46
|
+
* @param boolean - Indicates whether the config feature should be enabled or disabled.
|
|
47
|
+
* @returns The current CommandFeatureSelector instance.
|
|
48
|
+
* @throws Error if the command is native and the config feature is being configured.
|
|
49
|
+
*/
|
|
50
|
+
config(boolean?: boolean): this;
|
|
51
|
+
/**
|
|
52
|
+
* Enables or disables the presets feature.
|
|
53
|
+
* @param boolean - Indicates whether the presets feature should be enabled or disabled.
|
|
54
|
+
* @returns The current CommandFeatureSelector instance.
|
|
55
|
+
* @throws Error if the command is native and the presets feature is being configured.
|
|
56
|
+
*/
|
|
57
|
+
presets(boolean?: boolean): this;
|
|
58
|
+
/**
|
|
59
|
+
* Enables or disables the auto assign missing option flags feature.
|
|
60
|
+
* @param boolean - Indicates whether the auto assign missing option flags feature should be enabled or disabled.
|
|
61
|
+
* @returns The current CommandFeatureSelector instance.
|
|
62
|
+
*/
|
|
63
|
+
autoAssignMissingOptionFlags(boolean?: boolean): this;
|
|
64
|
+
/**
|
|
65
|
+
* Enables or disables the auto assign sub command aliases feature.
|
|
66
|
+
* @param boolean - Indicates whether the auto assign sub command aliases feature should be enabled or disabled.
|
|
67
|
+
* @returns The current CommandFeatureSelector instance.
|
|
68
|
+
*/
|
|
69
|
+
autoAssignSubCommandAliases(boolean?: boolean): this;
|
|
70
|
+
/**
|
|
71
|
+
* Helper method to enable or disable a feature.
|
|
72
|
+
* @param boolean - Indicates whether the auto assign sub command aliases feature should be enabled or disabled.
|
|
73
|
+
* @param prop - The property name to set.
|
|
74
|
+
* @param method - The method name to output in the debug message.
|
|
75
|
+
* @param throwIfNative - Indicates whether an error should be thrown if the command is native.
|
|
76
|
+
* @returns The current CommandFeatureSelector instance.
|
|
77
|
+
*/
|
|
78
|
+
protected setProperty(boolean: boolean | undefined, prop: keyof this, method: string, throwIfNative: boolean): this;
|
|
79
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
|
+
import { Any } from '../util/types/Any';
|
|
3
|
+
import { MethodDisabler } from '../util/function/MethodDisabler';
|
|
4
|
+
/**
|
|
5
|
+
* The OutputManager class manages the output of debug messages to the console.
|
|
6
|
+
*/
|
|
7
|
+
export declare class OutputManager {
|
|
8
|
+
/**
|
|
9
|
+
* The singleton instance of the OutputManager class.
|
|
10
|
+
*/
|
|
11
|
+
private static instance;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the singleton instance of the OutputManager class.
|
|
14
|
+
* If the instance does not exist, it creates a new one.
|
|
15
|
+
*/
|
|
16
|
+
static getInstance(): OutputManager;
|
|
17
|
+
/**
|
|
18
|
+
* Ansi-colors object
|
|
19
|
+
*/
|
|
20
|
+
readonly colors: typeof colors;
|
|
21
|
+
/**
|
|
22
|
+
* A MethodDisabler instance for disabling the write method of the process.stdout object.
|
|
23
|
+
*/
|
|
24
|
+
readonly stdout: MethodDisabler;
|
|
25
|
+
/**
|
|
26
|
+
* A MethodDisabler instance for disabling the write method of the process.stderr object.
|
|
27
|
+
*/
|
|
28
|
+
readonly stderr: MethodDisabler;
|
|
29
|
+
/**
|
|
30
|
+
* A MethodDisabler instance for disabling the debug method of the console object.
|
|
31
|
+
*/
|
|
32
|
+
readonly debug: MethodDisabler;
|
|
33
|
+
/**
|
|
34
|
+
* An array that holds queued debug messages.
|
|
35
|
+
*/
|
|
36
|
+
protected readonly debugMsgQueue: (() => Any)[];
|
|
37
|
+
/**
|
|
38
|
+
* Constructs a new instance of the OutputManager class.
|
|
39
|
+
* console.debug is disabled by default.
|
|
40
|
+
*/
|
|
41
|
+
constructor();
|
|
42
|
+
get queueSize(): number;
|
|
43
|
+
/**
|
|
44
|
+
* Resets the OutputManager to its default state.
|
|
45
|
+
* - Enables colors.
|
|
46
|
+
* - Enables the write method of the process.stdout object.
|
|
47
|
+
* - Enables the write method of the process.stderr object.
|
|
48
|
+
* - Disables the debug method of the console object.
|
|
49
|
+
* @returns The OutputManager instance.
|
|
50
|
+
*/
|
|
51
|
+
reset(): this;
|
|
52
|
+
/**
|
|
53
|
+
* Outputs a debug message to the console.
|
|
54
|
+
* If the debug method is enabled, the message is immediately logged to the console.
|
|
55
|
+
* Otherwise, the message is added to the debug message queue.
|
|
56
|
+
* @param fn - A function that returns the debug message.
|
|
57
|
+
*/
|
|
58
|
+
outputDebug(fn: () => Any): void;
|
|
59
|
+
/**
|
|
60
|
+
* Drains the debug message queue by logging all the messages to the console.
|
|
61
|
+
*/
|
|
62
|
+
drainDebugMessageQueue(): void;
|
|
63
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ArgumentBuilder } from '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export declare abstract class AbstractStringParserSelector<Builder extends ArgumentBuilder | OptionBuilder> extends Base {
|
|
1
|
+
import { ArgumentBuilder } from '../arg/ArgumentBuilder';
|
|
2
|
+
import { JsonValue } from '../util/types/JsonValue';
|
|
3
|
+
import { OptionBuilder } from '../opt/OptionBuilder';
|
|
4
|
+
import { TStringParser } from '../util/types/TStringParser';
|
|
5
|
+
export declare abstract class ParserSelector<Builder extends ArgumentBuilder | OptionBuilder> {
|
|
7
6
|
protected readonly builder: Builder;
|
|
8
7
|
constructor(builder: Builder);
|
|
9
8
|
abstract custom<T extends JsonValue>(parser: TStringParser<T>): Builder;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ArgumentBuilder } from '../arg/ArgumentBuilder';
|
|
2
|
+
import { JsonValue } from '../util/types/JsonValue';
|
|
3
|
+
import { OptionBuilder } from '../opt/OptionBuilder';
|
|
4
|
+
import { TValidator } from '../util/types/TValidator';
|
|
5
|
+
export declare abstract class ValidatorSelector<Builder extends OptionBuilder | ArgumentBuilder> {
|
|
6
|
+
protected readonly builder: Builder;
|
|
7
|
+
constructor(builder: Builder);
|
|
8
|
+
abstract custom<O>(validator: TValidator<O>): typeof this.builder;
|
|
9
|
+
isString(): Builder;
|
|
10
|
+
isNumber(): Builder;
|
|
11
|
+
isInteger(): Builder;
|
|
12
|
+
isStringArray(): Builder;
|
|
13
|
+
isNumberArray(): Builder;
|
|
14
|
+
isIntegerArray(): Builder;
|
|
15
|
+
arrayWhereEach<O extends JsonValue = JsonValue>(...validators: TValidator<O>[]): Builder;
|
|
16
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Any } from '../util/types/Any';
|
|
2
|
+
import { JsonFile } from './JsonFile';
|
|
3
|
+
import { JsonValue } from '../util/types/JsonValue';
|
|
4
|
+
/**
|
|
5
|
+
* A class that represents a section of the JSON file used as a simple database.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class AbstractJsonFileSection<Val = JsonValue> {
|
|
8
|
+
readonly file: JsonFile;
|
|
9
|
+
protected readonly name: string;
|
|
10
|
+
protected readonly keysAreFixed: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Indicates whether the section has been initialized.
|
|
13
|
+
*/
|
|
14
|
+
protected isInitialized: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The default values for the section.
|
|
17
|
+
*/
|
|
18
|
+
readonly defaultValues: Record<string, Val>;
|
|
19
|
+
/**
|
|
20
|
+
* The base string used as a prefix for the section.
|
|
21
|
+
*/
|
|
22
|
+
readonly prefixBaseString: string;
|
|
23
|
+
/**
|
|
24
|
+
* Creates an instance of AbstractJsonFileSection.
|
|
25
|
+
* @param file - The parent JsonFile instance.
|
|
26
|
+
* @param name - The name of the section.
|
|
27
|
+
* @param keysAreFixed - Indicates whether the keys in the section are fixed.
|
|
28
|
+
*/
|
|
29
|
+
constructor(file: JsonFile, name: string, keysAreFixed: boolean);
|
|
30
|
+
/**
|
|
31
|
+
* Asserts that a key-value pair is valid.
|
|
32
|
+
* @param key - The key to assert.
|
|
33
|
+
* @param value - The value to assert.
|
|
34
|
+
*/
|
|
35
|
+
abstract assertValid(key: string, value: Val): void;
|
|
36
|
+
/**
|
|
37
|
+
* Defines a property for the section.
|
|
38
|
+
* @param key - The key of the property.
|
|
39
|
+
* @param options - The options for the property.
|
|
40
|
+
*/
|
|
41
|
+
abstract defineProperty(key: string, options: Any): void;
|
|
42
|
+
/**
|
|
43
|
+
* Initializes the section.
|
|
44
|
+
* @param save - Indicates whether to save the section after initialization.
|
|
45
|
+
* @returns A string if an error occurred during initialization, otherwise void.
|
|
46
|
+
*/
|
|
47
|
+
abstract initialize(save?: boolean): void | string;
|
|
48
|
+
/**
|
|
49
|
+
* The JsonDB associated with the section.
|
|
50
|
+
*/
|
|
51
|
+
get db(): import("..").JsonDB;
|
|
52
|
+
/**
|
|
53
|
+
* The CommandBuilder associated with the section.
|
|
54
|
+
*/
|
|
55
|
+
get cmd(): import("..").CommandBuilder;
|
|
56
|
+
/**
|
|
57
|
+
* Saves the section.
|
|
58
|
+
* @returns A promise that resolves when the section is saved.
|
|
59
|
+
*/
|
|
60
|
+
save(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the object path prefix as dot-separated keys for this section of the JSON file database.
|
|
63
|
+
* @param key - An optional key to append to the prefix path.
|
|
64
|
+
* @returns The object path prefix.
|
|
65
|
+
* @throws An error if the keys are fixed and the specified key does not exist in the default values.
|
|
66
|
+
*/
|
|
67
|
+
prefix(key?: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the value associated with the specified key.
|
|
70
|
+
* @param key - The key to get the value for.
|
|
71
|
+
* @returns The value associated with the key.
|
|
72
|
+
*/
|
|
73
|
+
get<T extends Val = Val>(key: string): T;
|
|
74
|
+
/**
|
|
75
|
+
* Gets all the values in the section.
|
|
76
|
+
* @returns All the values in the section.
|
|
77
|
+
*/
|
|
78
|
+
getAll(): Record<string, Val>;
|
|
79
|
+
/**
|
|
80
|
+
* Gets the keys in the section.
|
|
81
|
+
* @returns The keys in the section.
|
|
82
|
+
*/
|
|
83
|
+
get keys(): string[];
|
|
84
|
+
/**
|
|
85
|
+
* Gets the number of keys in the section.
|
|
86
|
+
* @returns The number of keys in the section.
|
|
87
|
+
*/
|
|
88
|
+
count(): number;
|
|
89
|
+
/**
|
|
90
|
+
* Sets the value associated with the specified key.
|
|
91
|
+
* @param key - The key to set the value for.
|
|
92
|
+
* @param value - The value to set.
|
|
93
|
+
* @param save - Indicates whether to save the section after setting the value.
|
|
94
|
+
*/
|
|
95
|
+
set(key: string, value: Val, save?: boolean): void;
|
|
96
|
+
/**
|
|
97
|
+
* Sets all the values in the section.
|
|
98
|
+
* @param values - The values to set.
|
|
99
|
+
* @param save - Indicates whether to save the section after setting the values.
|
|
100
|
+
*/
|
|
101
|
+
setAll(values: typeof this.defaultValues, save?: boolean): void;
|
|
102
|
+
/**
|
|
103
|
+
* Updates the value associated with the specified key.
|
|
104
|
+
* @param key - The key to set the value for.
|
|
105
|
+
* @param callback - The callback function that returns the new value.
|
|
106
|
+
* @param save - Indicates whether to save the section after setting the value.
|
|
107
|
+
*/
|
|
108
|
+
update(key: string, callback: (val: Val, key: string) => Val, save?: boolean): void;
|
|
109
|
+
/**
|
|
110
|
+
* Resets the value associated with the specified key to its default value.
|
|
111
|
+
* @param key - The key to reset.
|
|
112
|
+
* @param save - Indicates whether to save the section after resetting the value.
|
|
113
|
+
*/
|
|
114
|
+
reset(key: string, save?: boolean): void;
|
|
115
|
+
/**
|
|
116
|
+
* Resets all the values in the section to their default values.
|
|
117
|
+
* @param save - Indicates whether to save the section after resetting the values.
|
|
118
|
+
*/
|
|
119
|
+
resetAll(save?: boolean): void;
|
|
120
|
+
/**
|
|
121
|
+
* Deletes the value associated with the specified key.
|
|
122
|
+
* @param key - The key to delete.
|
|
123
|
+
* @param save - Indicates whether to save the section after deleting the value.
|
|
124
|
+
*/
|
|
125
|
+
delete(key: string, save?: boolean): void;
|
|
126
|
+
/**
|
|
127
|
+
* Deletes all the values in the section.
|
|
128
|
+
* @param save - Indicates whether to save the section after deleting the values.
|
|
129
|
+
*/
|
|
130
|
+
deleteAll(save?: boolean): void;
|
|
131
|
+
/**
|
|
132
|
+
* Edits the values in the section using a text editor.
|
|
133
|
+
* @param editor - The text editor to use. If not specified, the default text editor command will be used.
|
|
134
|
+
*/
|
|
135
|
+
edit(editor?: string): void;
|
|
136
|
+
}
|