@blazetrails/thor 0.0.0-stage → 0.1.0-alpha0.2
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/LICENSE +21 -0
- package/NOTICE +9 -0
- package/dist/actions/create-file.d.ts +23 -0
- package/dist/actions/create-file.js +69 -0
- package/dist/actions/create-file.js.map +1 -0
- package/dist/actions/create-link.d.ts +10 -0
- package/dist/actions/create-link.js +34 -0
- package/dist/actions/create-link.js.map +1 -0
- package/dist/actions/directory.d.ts +31 -0
- package/dist/actions/directory.js +76 -0
- package/dist/actions/directory.js.map +1 -0
- package/dist/actions/empty-directory.d.ts +36 -0
- package/dist/actions/empty-directory.js +95 -0
- package/dist/actions/empty-directory.js.map +1 -0
- package/dist/actions/file-manipulation.d.ts +64 -0
- package/dist/actions/file-manipulation.js +190 -0
- package/dist/actions/file-manipulation.js.map +1 -0
- package/dist/actions/inject-into-file.d.ts +31 -0
- package/dist/actions/inject-into-file.js +111 -0
- package/dist/actions/inject-into-file.js.map +1 -0
- package/dist/actions.d.ts +120 -0
- package/dist/actions.js +287 -0
- package/dist/actions.js.map +1 -0
- package/dist/base.d.ts +223 -0
- package/dist/base.js +455 -0
- package/dist/base.js.map +1 -0
- package/dist/command.d.ts +69 -0
- package/dist/command.js +169 -0
- package/dist/command.js.map +1 -0
- package/dist/constants.generated.d.ts +2 -0
- package/dist/constants.generated.js +74 -0
- package/dist/constants.generated.js.map +1 -0
- package/dist/core-ext/hash-with-indifferent-access.d.ts +32 -0
- package/dist/core-ext/hash-with-indifferent-access.js +99 -0
- package/dist/core-ext/hash-with-indifferent-access.js.map +1 -0
- package/dist/error.d.ts +62 -0
- package/dist/error.js +105 -0
- package/dist/error.js.map +1 -0
- package/dist/group.d.ts +66 -0
- package/dist/group.js +313 -0
- package/dist/group.js.map +1 -0
- package/dist/invocation.d.ts +63 -0
- package/dist/invocation.js +104 -0
- package/dist/invocation.js.map +1 -0
- package/dist/line-editor/basic.d.ts +12 -0
- package/dist/line-editor/basic.js +30 -0
- package/dist/line-editor/basic.js.map +1 -0
- package/dist/line-editor.d.ts +4 -0
- package/dist/line-editor.js +9 -0
- package/dist/line-editor.js.map +1 -0
- package/dist/nested-context.d.ts +12 -0
- package/dist/nested-context.js +28 -0
- package/dist/nested-context.js.map +1 -0
- package/dist/parser/argument.d.ts +34 -0
- package/dist/parser/argument.js +103 -0
- package/dist/parser/argument.js.map +1 -0
- package/dist/parser/arguments.d.ts +42 -0
- package/dist/parser/arguments.js +164 -0
- package/dist/parser/arguments.js.map +1 -0
- package/dist/parser/option.d.ts +45 -0
- package/dist/parser/option.js +164 -0
- package/dist/parser/option.js.map +1 -0
- package/dist/parser/options.d.ts +69 -0
- package/dist/parser/options.js +332 -0
- package/dist/parser/options.js.map +1 -0
- package/dist/shell/basic.d.ts +64 -0
- package/dist/shell/basic.js +288 -0
- package/dist/shell/basic.js.map +1 -0
- package/dist/shell/color.d.ts +29 -0
- package/dist/shell/color.js +52 -0
- package/dist/shell/color.js.map +1 -0
- package/dist/shell/column-printer.d.ts +16 -0
- package/dist/shell/column-printer.js +28 -0
- package/dist/shell/column-printer.js.map +1 -0
- package/dist/shell/table-printer.d.ts +31 -0
- package/dist/shell/table-printer.js +120 -0
- package/dist/shell/table-printer.js.map +1 -0
- package/dist/shell/terminal.d.ts +4 -0
- package/dist/shell/terminal.js +35 -0
- package/dist/shell/terminal.js.map +1 -0
- package/dist/shell/wrapped-printer.d.ts +5 -0
- package/dist/shell/wrapped-printer.js +37 -0
- package/dist/shell/wrapped-printer.js.map +1 -0
- package/dist/shell.d.ts +51 -0
- package/dist/shell.js +129 -0
- package/dist/shell.js.map +1 -0
- package/dist/thor.d.ts +174 -0
- package/dist/thor.js +640 -0
- package/dist/thor.js.map +1 -0
- package/dist/util.d.ts +16 -0
- package/dist/util.js +87 -0
- package/dist/util.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +55 -3
- package/README.md +0 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { puts, stringSplit, strlen } from "@blazetrails/ruby-compat";
|
|
2
|
+
import { ColumnPrinter } from "./column-printer.js";
|
|
3
|
+
import * as Terminal from "./terminal.js";
|
|
4
|
+
export class WrappedPrinter extends ColumnPrinter {
|
|
5
|
+
print(message) {
|
|
6
|
+
const width = Terminal.terminalWidth() - this._indent;
|
|
7
|
+
let paras = stringSplit(message, "\n\n");
|
|
8
|
+
paras = paras
|
|
9
|
+
.map((unwrapped) => {
|
|
10
|
+
const words = stringSplit(unwrapped, " ");
|
|
11
|
+
let counter = strlen(words[0]);
|
|
12
|
+
return words.reduce((memo, word) => {
|
|
13
|
+
word = word.replaceAll("\n\x05", "\n").replaceAll("\x05", "\n");
|
|
14
|
+
if (word.includes("\n"))
|
|
15
|
+
counter = 0;
|
|
16
|
+
if (counter + strlen(word) + 1 < width) {
|
|
17
|
+
memo = `${memo} ${word}`;
|
|
18
|
+
counter += strlen(word) + 1;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
memo = `${memo}\n${word}`;
|
|
22
|
+
counter = strlen(word);
|
|
23
|
+
}
|
|
24
|
+
return memo;
|
|
25
|
+
});
|
|
26
|
+
})
|
|
27
|
+
.filter((x) => x != null);
|
|
28
|
+
paras.forEach((para) => {
|
|
29
|
+
stringSplit(para, "\n").forEach((line) => {
|
|
30
|
+
puts.call(this.stdout, " ".repeat(this._indent) + line);
|
|
31
|
+
});
|
|
32
|
+
if (para !== paras.at(-1))
|
|
33
|
+
puts.call(this.stdout);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=wrapped-printer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapped-printer.js","sourceRoot":"","sources":["../../lib/shell/wrapped-printer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,E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AC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;QAE5B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACvC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;YAC1D,CAAC,CAAC,CAAC;YACH,IAAI,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/shell.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Basic } from "./shell/basic.js";
|
|
2
|
+
import { Color } from "./shell/color.js";
|
|
3
|
+
type ShellClass = new () => Basic;
|
|
4
|
+
declare const singleton: {
|
|
5
|
+
/** @internal */
|
|
6
|
+
_shell: ShellClass | null;
|
|
7
|
+
set shell(shell: ShellClass | null);
|
|
8
|
+
get shell(): ShellClass;
|
|
9
|
+
};
|
|
10
|
+
export declare const Base: typeof singleton;
|
|
11
|
+
export interface Shell {
|
|
12
|
+
/** @internal */
|
|
13
|
+
_shell?: Basic | null;
|
|
14
|
+
shell: Basic;
|
|
15
|
+
ask: OmitThisParameter<typeof ask>;
|
|
16
|
+
error: OmitThisParameter<typeof error>;
|
|
17
|
+
setColor: OmitThisParameter<typeof setColor>;
|
|
18
|
+
isYes: OmitThisParameter<typeof isYes>;
|
|
19
|
+
isNo: OmitThisParameter<typeof isNo>;
|
|
20
|
+
say: OmitThisParameter<typeof say>;
|
|
21
|
+
sayError: OmitThisParameter<typeof sayError>;
|
|
22
|
+
sayStatus: OmitThisParameter<typeof sayStatus>;
|
|
23
|
+
printInColumns: OmitThisParameter<typeof printInColumns>;
|
|
24
|
+
printTable: OmitThisParameter<typeof printTable>;
|
|
25
|
+
printWrapped: OmitThisParameter<typeof printWrapped>;
|
|
26
|
+
fileCollision: OmitThisParameter<typeof fileCollision>;
|
|
27
|
+
terminalWidth: OmitThisParameter<typeof terminalWidth>;
|
|
28
|
+
withPadding: OmitThisParameter<typeof withPadding>;
|
|
29
|
+
}
|
|
30
|
+
declare function ask(this: Shell, ...args: Parameters<Basic["ask"]>): ReturnType<Basic["ask"]>;
|
|
31
|
+
declare function error(this: Shell, ...args: Parameters<Basic["error"]>): void;
|
|
32
|
+
declare function setColor(this: Shell, ...args: Parameters<Basic["setColor"]>): string;
|
|
33
|
+
declare function isYes(this: Shell, ...args: Parameters<Basic["isYes"]>): ReturnType<Basic["isYes"]>;
|
|
34
|
+
declare function isNo(this: Shell, ...args: Parameters<Basic["isNo"]>): ReturnType<Basic["isNo"]>;
|
|
35
|
+
declare function say(this: Shell, ...args: Parameters<Basic["say"]>): void;
|
|
36
|
+
declare function sayError(this: Shell, ...args: Parameters<Basic["sayError"]>): void;
|
|
37
|
+
declare function sayStatus(this: Shell, ...args: Parameters<Basic["sayStatus"]>): void;
|
|
38
|
+
declare function printInColumns(this: Shell, ...args: Parameters<Basic["printInColumns"]>): void;
|
|
39
|
+
declare function printTable(this: Shell, ...args: Parameters<Basic["printTable"]>): void;
|
|
40
|
+
declare function printWrapped(this: Shell, ...args: Parameters<Basic["printWrapped"]>): void;
|
|
41
|
+
declare function fileCollision(this: Shell, ...args: Parameters<Basic["fileCollision"]>): ReturnType<Basic["fileCollision"]>;
|
|
42
|
+
declare function terminalWidth(this: Shell): number;
|
|
43
|
+
declare function withPadding<T>(this: Shell, block: () => T): T;
|
|
44
|
+
export declare const Shell: {
|
|
45
|
+
SHELL_DELEGATED_METHODS: string[];
|
|
46
|
+
Basic: typeof Basic;
|
|
47
|
+
Color: typeof Color;
|
|
48
|
+
HTML?: typeof Basic;
|
|
49
|
+
} & Record<string, unknown>;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=shell.d.ts.map
|
package/dist/shell.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { env, RbConfig, rbCallSuper, constGet, rbEnsure } from "@blazetrails/ruby-compat";
|
|
2
|
+
import { Basic } from "./shell/basic.js";
|
|
3
|
+
import { Color } from "./shell/color.js";
|
|
4
|
+
import * as Terminal from "./shell/terminal.js";
|
|
5
|
+
const singleton = {
|
|
6
|
+
/** @internal */
|
|
7
|
+
_shell: null,
|
|
8
|
+
set shell(shell) {
|
|
9
|
+
this._shell = shell;
|
|
10
|
+
},
|
|
11
|
+
get shell() {
|
|
12
|
+
if (this._shell == null) {
|
|
13
|
+
if (env["THOR_SHELL"] != null && env["THOR_SHELL"] !== "") {
|
|
14
|
+
this._shell = constGet(Shell, env["THOR_SHELL"]);
|
|
15
|
+
}
|
|
16
|
+
else if (/mswin|mingw/.test(RbConfig.CONFIG["host_os"]) && env["ANSICON"] == null) {
|
|
17
|
+
this._shell = Shell.Basic;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this._shell = Shell.Color;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return this._shell;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const singletonMethods = Object.getOwnPropertyDescriptors(singleton);
|
|
27
|
+
for (const descriptor of Object.values(singletonMethods))
|
|
28
|
+
descriptor.enumerable = false;
|
|
29
|
+
export const Base = Object.defineProperties({}, singletonMethods);
|
|
30
|
+
const SHELL_DELEGATED_METHODS = [
|
|
31
|
+
"ask",
|
|
32
|
+
"error",
|
|
33
|
+
"setColor",
|
|
34
|
+
"isYes",
|
|
35
|
+
"isNo",
|
|
36
|
+
"say",
|
|
37
|
+
"sayError",
|
|
38
|
+
"sayStatus",
|
|
39
|
+
"printInColumns",
|
|
40
|
+
"printTable",
|
|
41
|
+
"printWrapped",
|
|
42
|
+
"fileCollision",
|
|
43
|
+
"terminalWidth",
|
|
44
|
+
];
|
|
45
|
+
function setShell(shell) {
|
|
46
|
+
this._shell = shell;
|
|
47
|
+
}
|
|
48
|
+
function shell() {
|
|
49
|
+
return (this._shell ??= new Base.shell());
|
|
50
|
+
}
|
|
51
|
+
function ask(...args) {
|
|
52
|
+
return this.shell.ask(...args);
|
|
53
|
+
}
|
|
54
|
+
function error(...args) {
|
|
55
|
+
return this.shell.error(...args);
|
|
56
|
+
}
|
|
57
|
+
function setColor(...args) {
|
|
58
|
+
return this.shell.setColor(...args);
|
|
59
|
+
}
|
|
60
|
+
function isYes(...args) {
|
|
61
|
+
return this.shell.isYes(...args);
|
|
62
|
+
}
|
|
63
|
+
function isNo(...args) {
|
|
64
|
+
return this.shell.isNo(...args);
|
|
65
|
+
}
|
|
66
|
+
function say(...args) {
|
|
67
|
+
return this.shell.say(...args);
|
|
68
|
+
}
|
|
69
|
+
function sayError(...args) {
|
|
70
|
+
return this.shell.sayError(...args);
|
|
71
|
+
}
|
|
72
|
+
function sayStatus(...args) {
|
|
73
|
+
return this.shell.sayStatus(...args);
|
|
74
|
+
}
|
|
75
|
+
function printInColumns(...args) {
|
|
76
|
+
return this.shell.printInColumns(...args);
|
|
77
|
+
}
|
|
78
|
+
function printTable(...args) {
|
|
79
|
+
return this.shell.printTable(...args);
|
|
80
|
+
}
|
|
81
|
+
function printWrapped(...args) {
|
|
82
|
+
return this.shell.printWrapped(...args);
|
|
83
|
+
}
|
|
84
|
+
function fileCollision(...args) {
|
|
85
|
+
return this.shell.fileCollision(...args);
|
|
86
|
+
}
|
|
87
|
+
function terminalWidth() {
|
|
88
|
+
return this.shell.terminalWidth();
|
|
89
|
+
}
|
|
90
|
+
function withPadding(block) {
|
|
91
|
+
this.shell.padding += 1;
|
|
92
|
+
return rbEnsure(block, () => {
|
|
93
|
+
this.shell.padding -= 1;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/** @internal */
|
|
97
|
+
function _sharedConfiguration() {
|
|
98
|
+
return Object.assign(rbCallSuper(this, _sharedConfiguration), {
|
|
99
|
+
shell: this.shell,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
export const Shell = {
|
|
103
|
+
SHELL_DELEGATED_METHODS,
|
|
104
|
+
Basic,
|
|
105
|
+
Color,
|
|
106
|
+
Terminal,
|
|
107
|
+
ask,
|
|
108
|
+
error,
|
|
109
|
+
setColor,
|
|
110
|
+
isYes,
|
|
111
|
+
isNo,
|
|
112
|
+
say,
|
|
113
|
+
sayError,
|
|
114
|
+
sayStatus,
|
|
115
|
+
printInColumns,
|
|
116
|
+
printTable,
|
|
117
|
+
printWrapped,
|
|
118
|
+
fileCollision,
|
|
119
|
+
terminalWidth,
|
|
120
|
+
withPadding,
|
|
121
|
+
_sharedConfiguration,
|
|
122
|
+
};
|
|
123
|
+
Object.defineProperty(Shell, "shell", {
|
|
124
|
+
get: shell,
|
|
125
|
+
set: setShell,
|
|
126
|
+
enumerable: true,
|
|
127
|
+
configurable: true,
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../lib/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAIhD,MAAM,SAAS,GAAG;IAChB,gBAAgB;IAChB,MAAM,EAAE,IAAyB;IAEjC,IAAI,KAAK,CAAC,KAAwB;QAChC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,KAAK;QACP,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,E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, type BaseClass, type BaseConfig } from "./base.js";
|
|
2
|
+
import { Command, DynamicCommand } from "./command.js";
|
|
3
|
+
import { Group, type GroupClass } from "./group.js";
|
|
4
|
+
import { Option, type OptionOptions } from "./parser/option.js";
|
|
5
|
+
import type { Basic } from "./shell/basic.js";
|
|
6
|
+
import * as LineEditor from "./line-editor.js";
|
|
7
|
+
import * as Util from "./util.js";
|
|
8
|
+
type Mappings = Record<string, string> | Map<unknown, string>;
|
|
9
|
+
type DescOptions = {
|
|
10
|
+
for?: string;
|
|
11
|
+
hide?: unknown;
|
|
12
|
+
};
|
|
13
|
+
type LongDescOptions = {
|
|
14
|
+
for?: string;
|
|
15
|
+
wrap?: unknown;
|
|
16
|
+
};
|
|
17
|
+
type CheckUnknownOptions = {
|
|
18
|
+
only?: unknown;
|
|
19
|
+
except?: unknown;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
type Config = {
|
|
23
|
+
currentCommand?: Command | null;
|
|
24
|
+
};
|
|
25
|
+
type Instance = Base & {
|
|
26
|
+
shell: Basic;
|
|
27
|
+
invoke(...args: unknown[]): unknown;
|
|
28
|
+
invokeCommand(command: Command, ...args: unknown[]): Promise<unknown>;
|
|
29
|
+
};
|
|
30
|
+
export type ThorClass = typeof Thor & Omit<BaseClass, keyof typeof Thor>;
|
|
31
|
+
export declare class Thor {
|
|
32
|
+
/** @noRailsEquivalent PERMANENT */
|
|
33
|
+
static start: BaseClass["start"];
|
|
34
|
+
static Group: typeof Group;
|
|
35
|
+
static LineEditor: typeof LineEditor;
|
|
36
|
+
static Util: typeof Util;
|
|
37
|
+
/** @internal */
|
|
38
|
+
static _packageName?: string | null;
|
|
39
|
+
/** @internal */
|
|
40
|
+
static _defaultCommand?: string;
|
|
41
|
+
/** @internal */
|
|
42
|
+
static _usage?: string | string[] | null;
|
|
43
|
+
/** @internal */
|
|
44
|
+
static _desc?: string | null;
|
|
45
|
+
/** @internal */
|
|
46
|
+
static _hide?: unknown;
|
|
47
|
+
/** @internal */
|
|
48
|
+
static _longDesc?: string | null;
|
|
49
|
+
/** @internal */
|
|
50
|
+
static _longDescWrap?: boolean | null;
|
|
51
|
+
/** @internal */
|
|
52
|
+
static _map?: Record<string, string>;
|
|
53
|
+
/** @internal */
|
|
54
|
+
static _methodOptions?: Record<string, Option> | null;
|
|
55
|
+
/** @internal */
|
|
56
|
+
static _subcommands?: string[];
|
|
57
|
+
/** @internal */
|
|
58
|
+
static _subcommandClasses?: Record<string, ThorClass>;
|
|
59
|
+
/** @internal */
|
|
60
|
+
static _stopOnUnknownOption?: string[];
|
|
61
|
+
/** @internal */
|
|
62
|
+
static _disableRequiredCheck?: string[];
|
|
63
|
+
/** @internal */
|
|
64
|
+
static _methodExclusiveOptionNames?: string[][] | null;
|
|
65
|
+
/** @internal */
|
|
66
|
+
static _methodAtLeastOneOptionNames?: string[][] | null;
|
|
67
|
+
static packageName(this: ThorClass, name: string | null, _?: object): string | null;
|
|
68
|
+
static defaultCommand(this: ThorClass, meth?: string | null): string;
|
|
69
|
+
static defaultTask: typeof Thor.defaultCommand;
|
|
70
|
+
static register(this: ThorClass, klass: ThorClass | GroupClass, subcommandName: string, usage: string, description: string, options?: DescOptions): void;
|
|
71
|
+
static desc(this: ThorClass, usage: string | string[] | null, description: string | null, options?: DescOptions): void;
|
|
72
|
+
static longDesc(this: ThorClass, longDescription: string | null, options?: LongDescOptions): void;
|
|
73
|
+
static map(this: ThorClass, mappings?: Mappings | null, kw?: Record<string, string>): Record<string, string>;
|
|
74
|
+
static methodOptions(this: ThorClass, options?: Record<string, unknown> | null): Record<string, Option>;
|
|
75
|
+
static options: typeof Thor.methodOptions;
|
|
76
|
+
static methodOption(this: ThorClass, name: string, options?: OptionOptions & {
|
|
77
|
+
for?: string;
|
|
78
|
+
}): Option;
|
|
79
|
+
static option: typeof Thor.methodOption;
|
|
80
|
+
static methodExclusive(this: ThorClass, ...args: unknown[]): void;
|
|
81
|
+
static exclusive: typeof Thor.methodExclusive;
|
|
82
|
+
static methodAtLeastOne(this: ThorClass, ...args: unknown[]): void;
|
|
83
|
+
static atLeastOne: typeof Thor.methodAtLeastOne;
|
|
84
|
+
static commandHelp(this: ThorClass, shell: Basic, commandName: string): void;
|
|
85
|
+
static taskHelp: typeof Thor.commandHelp;
|
|
86
|
+
static help(this: ThorClass, shell: Basic, subcommand?: unknown): Promise<void>;
|
|
87
|
+
static printableCommands(this: ThorClass, all?: unknown, subcommand?: unknown): string[][];
|
|
88
|
+
static printableTasks: typeof Thor.printableCommands;
|
|
89
|
+
static subcommands(this: ThorClass): string[];
|
|
90
|
+
static subtasks: typeof Thor.subcommands;
|
|
91
|
+
static subcommandClasses(this: ThorClass): Record<string, ThorClass>;
|
|
92
|
+
static subcommand(this: ThorClass, subcommand: string, subcommandClass: ThorClass): void;
|
|
93
|
+
static subtask: typeof Thor.subcommand;
|
|
94
|
+
static checkUnknownOptionsBang(this: ThorClass, options?: CheckUnknownOptions): unknown;
|
|
95
|
+
static isCheckUnknownOptions(this: ThorClass, config: Config): boolean;
|
|
96
|
+
static stopOnUnknownOptionBang(this: ThorClass, ...commandNames: string[]): string[];
|
|
97
|
+
static isStopOnUnknownOption(this: ThorClass, command: Command | null): boolean;
|
|
98
|
+
static disableRequiredCheckBang(this: ThorClass, ...commandNames: string[]): string[];
|
|
99
|
+
static isDisableRequiredCheck(this: ThorClass, command: Command | null): boolean;
|
|
100
|
+
static isCommandExists(this: ThorClass, commandName: string): boolean;
|
|
101
|
+
/** @internal */
|
|
102
|
+
static methodExclusiveOptionNames(this: ThorClass): string[][];
|
|
103
|
+
/** @internal */
|
|
104
|
+
static methodAtLeastOneOptionNames(this: ThorClass): string[][];
|
|
105
|
+
/** @internal */
|
|
106
|
+
protected static stopOnUnknownOption(this: ThorClass): string[];
|
|
107
|
+
/** @internal */
|
|
108
|
+
protected static disableRequiredCheck(this: ThorClass): string[];
|
|
109
|
+
/** @internal */
|
|
110
|
+
static printExclusiveOptions(this: ThorClass, shell: Basic, command?: Command | null): void;
|
|
111
|
+
/** @internal */
|
|
112
|
+
static printAtLeastOneRequiredOptions(this: ThorClass, shell: Basic, command?: Command | null): void;
|
|
113
|
+
/** @internal */
|
|
114
|
+
static dispatch(this: ThorClass, meth: string | null | undefined, givenArgs: unknown[], givenOpts: unknown[] | Record<string, unknown> | null, config: BaseConfig, block?: (instance: Instance) => void): Promise<unknown>;
|
|
115
|
+
/** @internal */
|
|
116
|
+
static banner(this: ThorClass, command: Command, namespace?: unknown, subcommand?: unknown): string;
|
|
117
|
+
/** @internal */
|
|
118
|
+
static baseclass(this: ThorClass): typeof Thor;
|
|
119
|
+
/** @internal */
|
|
120
|
+
static dynamicCommandClass(this: ThorClass): typeof DynamicCommand;
|
|
121
|
+
/**
|
|
122
|
+
* @internal
|
|
123
|
+
* @inventedArm kebabCase — PERMANENT
|
|
124
|
+
*/
|
|
125
|
+
static createCommand(this: ThorClass, meth: string): boolean;
|
|
126
|
+
/** @internal */
|
|
127
|
+
static createTask: typeof Thor.createCommand;
|
|
128
|
+
/** @internal */
|
|
129
|
+
static initializeAdded(this: ThorClass): void;
|
|
130
|
+
/** @internal */
|
|
131
|
+
static retrieveCommandName(this: ThorClass, args: unknown[]): string | null | undefined;
|
|
132
|
+
/** @internal */
|
|
133
|
+
static retrieveTaskName: typeof Thor.retrieveCommandName;
|
|
134
|
+
/**
|
|
135
|
+
* @internal
|
|
136
|
+
* @inventedArm kebabCase — PERMANENT
|
|
137
|
+
*/
|
|
138
|
+
static normalizeCommandName(this: ThorClass, meth: string | null | undefined): string;
|
|
139
|
+
/** @internal */
|
|
140
|
+
static normalizeTaskName: typeof Thor.normalizeCommandName;
|
|
141
|
+
/**
|
|
142
|
+
* @internal
|
|
143
|
+
* @inventedArm replaceAll — PERMANENT
|
|
144
|
+
*/
|
|
145
|
+
static findCommandPossibilities(this: ThorClass, meth: string): string[];
|
|
146
|
+
/** @internal */
|
|
147
|
+
static findTaskPossibilities: typeof Thor.findCommandPossibilities;
|
|
148
|
+
/** @internal */
|
|
149
|
+
static subcommandHelp(this: ThorClass, cmd: string): void;
|
|
150
|
+
/** @internal */
|
|
151
|
+
static subtaskHelp: typeof Thor.subcommandHelp;
|
|
152
|
+
/** @internal */
|
|
153
|
+
static sortCommandsBang(this: ThorClass, list: string[][]): string[][];
|
|
154
|
+
/**
|
|
155
|
+
* @inlinedFrom Thor::Shell#initialize thor/v1.4.0/lib/thor/shell.rb:44-48
|
|
156
|
+
* @inlinedFrom Thor::Invocation#initialize thor/v1.4.0/lib/thor/invocation.rb:23-27
|
|
157
|
+
* @inlinedFrom Thor::Base#initialize thor/v1.4.0/lib/thor/base.rb:53-113
|
|
158
|
+
* @inventedArm if — PERMANENT
|
|
159
|
+
*/
|
|
160
|
+
constructor(args?: unknown[], localOptions?: unknown, config?: BaseConfig & {
|
|
161
|
+
behavior?: string | null;
|
|
162
|
+
destinationRoot?: string | null;
|
|
163
|
+
shell?: Basic | null;
|
|
164
|
+
});
|
|
165
|
+
help(command?: string | null, subcommand?: unknown): Promise<void>;
|
|
166
|
+
}
|
|
167
|
+
import "./constants.generated.js";
|
|
168
|
+
declare module "@blazetrails/ruby-compat/object" {
|
|
169
|
+
interface TopLevelConstants {
|
|
170
|
+
Thor?: typeof Thor;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
export {};
|
|
174
|
+
//# sourceMappingURL=thor.d.ts.map
|