@h3ravel/console 11.0.5 → 11.0.7
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/bin/chunk-6Z5DP356.js +1 -0
- package/bin/lexer-DQCqS3nf-XQPNMZG6.js +4 -0
- package/bin/run.cjs +6 -6
- package/bin/run.js +6 -6
- package/dist/Commands/MigrateCommand.cjs +0 -2
- package/dist/Commands/MigrateCommand.js +1 -1
- package/dist/Commands/ServeCommand.cjs +1 -1
- package/dist/Commands/ServeCommand.js +1 -1
- package/dist/IO/app.cjs +24 -13
- package/dist/IO/app.js +7 -7
- package/dist/IO/providers.cjs +24 -5
- package/dist/IO/providers.js +6 -6
- package/dist/Kernel.cjs +1 -3
- package/dist/Kernel.js +4 -4
- package/dist/Musket.cjs +1 -3
- package/dist/Musket.js +3 -3
- package/dist/Providers/ConsoleServiceProvider.cjs +11 -3
- package/dist/Providers/ConsoleServiceProvider.js +5 -5
- package/dist/chunk-23QH5R54.js +27 -0
- package/dist/chunk-3ASEWMRX.js +37 -0
- package/dist/chunk-3RX6CLNR.js +32 -0
- package/dist/chunk-6OIH6FS4.js +32 -0
- package/dist/chunk-7EWRZPTX.js +63 -0
- package/dist/chunk-7PUQ5ZIN.js +6 -0
- package/dist/chunk-A5AONVOH.js +6 -0
- package/dist/chunk-ADIVRUAJ.js +27 -0
- package/dist/chunk-CCEWV2BR.js +39 -0
- package/dist/chunk-DXQTBFGG.js +31 -0
- package/dist/chunk-E4SSLXFT.js +63 -0
- package/dist/chunk-EIOQKTRM.js +104 -0
- package/dist/chunk-G4OE26TZ.js +33 -0
- package/dist/chunk-K3GOQSS3.js +6 -0
- package/dist/chunk-KCJKQP37.js +133 -0
- package/dist/chunk-KZA3MC77.js +151 -0
- package/dist/chunk-LLL3V7LB.js +6 -0
- package/dist/chunk-LQ6DL2HS.js +68 -0
- package/dist/chunk-MPXPSSLJ.js +133 -0
- package/dist/chunk-NFRXMBRP.js +24 -0
- package/dist/chunk-NVPKTRMT.js +7 -0
- package/dist/chunk-ORPRWIQ2.js +33 -0
- package/dist/chunk-PBNCVQZC.js +6 -0
- package/dist/chunk-PYSJMSNM.js +27 -0
- package/dist/chunk-Q3OMG6YH.js +186 -0
- package/dist/chunk-QCNBVSFO.js +68 -0
- package/dist/chunk-QMEO4OUR.js +151 -0
- package/dist/chunk-QSQNELZQ.js +83 -0
- package/dist/chunk-T6OOKENF.js +6 -0
- package/dist/chunk-TBDROT3I.js +6356 -0
- package/dist/chunk-TH2RWMWA.js +133 -0
- package/dist/chunk-UWCTG2LX.js +24 -0
- package/dist/chunk-WO2BXMBQ.js +6 -0
- package/dist/chunk-XAWZUZVP.js +32 -0
- package/dist/chunk-XD2Q7LWE.js +24 -0
- package/dist/chunk-XUYTJO6X.js +104 -0
- package/dist/chunk-YRUCICBV.js +24 -0
- package/dist/chunk-Z5XE72Q5.js +68 -0
- package/dist/index.cjs +25 -13
- package/dist/index.js +8 -8
- package/dist/lexer-DQCqS3nf-6W2BHF4T.js +68 -0
- package/dist/run.cjs +27 -13
- package/dist/run.js +8 -8
- package/package.json +7 -2
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-CCEWV2BR.js";
|
|
4
|
+
|
|
5
|
+
// src/Utils.ts
|
|
6
|
+
import { access } from "fs/promises";
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
|
|
9
|
+
// ../../node_modules/.pnpm/escalade@3.2.0/node_modules/escalade/sync/index.mjs
|
|
10
|
+
import { dirname, resolve } from "path";
|
|
11
|
+
import { readdirSync, statSync } from "fs";
|
|
12
|
+
function sync_default(start, callback) {
|
|
13
|
+
let dir = resolve(".", start);
|
|
14
|
+
let tmp, stats = statSync(dir);
|
|
15
|
+
if (!stats.isDirectory()) {
|
|
16
|
+
dir = dirname(dir);
|
|
17
|
+
}
|
|
18
|
+
while (true) {
|
|
19
|
+
tmp = callback(dir, readdirSync(dir));
|
|
20
|
+
if (tmp) return resolve(dir, tmp);
|
|
21
|
+
dir = dirname(tmp = dir);
|
|
22
|
+
if (tmp === dir) break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
__name(sync_default, "default");
|
|
26
|
+
|
|
27
|
+
// src/Utils.ts
|
|
28
|
+
import path from "path";
|
|
29
|
+
var join = path.join;
|
|
30
|
+
var Utils = class {
|
|
31
|
+
static {
|
|
32
|
+
__name(this, "Utils");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Wraps text with chalk
|
|
36
|
+
*
|
|
37
|
+
* @param txt
|
|
38
|
+
* @param color
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
static textFormat(txt, color) {
|
|
42
|
+
return String(txt).split(":").map((e, i, a) => i == 0 && a.length > 1 ? color(" " + e + ": ") : e).join("");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Ouput formater object
|
|
46
|
+
*
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
static output() {
|
|
50
|
+
return {
|
|
51
|
+
success: /* @__PURE__ */ __name((msg, exit = false) => {
|
|
52
|
+
console.log(chalk.green("\u2713"), this.textFormat(msg, chalk.bgGreen), "\n");
|
|
53
|
+
if (exit) process.exit(0);
|
|
54
|
+
}, "success"),
|
|
55
|
+
info: /* @__PURE__ */ __name((msg, exit = false) => {
|
|
56
|
+
console.log(chalk.blue("\u2139"), this.textFormat(msg, chalk.bgBlue), "\n");
|
|
57
|
+
if (exit) process.exit(0);
|
|
58
|
+
}, "info"),
|
|
59
|
+
error: /* @__PURE__ */ __name((msg, exit = true) => {
|
|
60
|
+
if (msg instanceof Error) {
|
|
61
|
+
if (msg.message) {
|
|
62
|
+
console.error(chalk.red("\u2716"), this.textFormat("ERROR:" + msg.message, chalk.bgRed));
|
|
63
|
+
}
|
|
64
|
+
console.error(chalk.red(`${msg.detail ? `${msg.detail}
|
|
65
|
+
` : ""}${msg.stack}`), "\n");
|
|
66
|
+
} else {
|
|
67
|
+
console.error(chalk.red("\u2716"), this.textFormat(msg, chalk.bgRed), "\n");
|
|
68
|
+
}
|
|
69
|
+
if (exit) process.exit(1);
|
|
70
|
+
}, "error"),
|
|
71
|
+
split: /* @__PURE__ */ __name((name, value, status, exit = false) => {
|
|
72
|
+
status ??= "info";
|
|
73
|
+
const color = {
|
|
74
|
+
success: chalk.bgGreen,
|
|
75
|
+
info: chalk.bgBlue,
|
|
76
|
+
error: chalk.bgRed
|
|
77
|
+
};
|
|
78
|
+
const regex = /\x1b\[\d+m/g;
|
|
79
|
+
const width = Math.min(process.stdout.columns, 100);
|
|
80
|
+
const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
|
|
81
|
+
console.log(this.textFormat(name, color[status]), chalk.gray(".".repeat(dots)), value);
|
|
82
|
+
if (exit) process.exit(0);
|
|
83
|
+
}, "split"),
|
|
84
|
+
quiet: /* @__PURE__ */ __name(() => {
|
|
85
|
+
process.exit(0);
|
|
86
|
+
}, "quiet")
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
static findModulePkg(moduleId, cwd) {
|
|
90
|
+
const parts = moduleId.replace(/\\/g, "/").split("/");
|
|
91
|
+
let packageName = "";
|
|
92
|
+
if (parts.length > 0 && parts[0][0] === "@") {
|
|
93
|
+
packageName += parts.shift() + "/";
|
|
94
|
+
}
|
|
95
|
+
packageName += parts.shift();
|
|
96
|
+
const packageJson = path.join(cwd ?? process.cwd(), "node_modules", packageName);
|
|
97
|
+
const resolved = this.findUpConfig(packageJson, "package", [
|
|
98
|
+
"json"
|
|
99
|
+
]);
|
|
100
|
+
if (!resolved) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
return path.join(path.dirname(resolved), parts.join("/"));
|
|
104
|
+
}
|
|
105
|
+
static async getMigrationPaths(cwd, migrator, defaultPath, path2) {
|
|
106
|
+
if (path2) {
|
|
107
|
+
return [
|
|
108
|
+
join(cwd, path2)
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
return [
|
|
112
|
+
...migrator.getPaths(),
|
|
113
|
+
join(cwd, defaultPath)
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
static twoColumnDetail(name, value) {
|
|
117
|
+
const regex = /\x1b\[\d+m/g;
|
|
118
|
+
const width = Math.min(process.stdout.columns, 100);
|
|
119
|
+
const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
|
|
120
|
+
return console.log(name, chalk.gray(".".repeat(dots)), value);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Check if file exists
|
|
124
|
+
*
|
|
125
|
+
* @param path
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
static async fileExists(path2) {
|
|
129
|
+
try {
|
|
130
|
+
await access(path2);
|
|
131
|
+
return true;
|
|
132
|
+
} catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
static findUpConfig(cwd, name, extensions) {
|
|
137
|
+
return sync_default(cwd, (_dir, names) => {
|
|
138
|
+
for (const ext of extensions) {
|
|
139
|
+
const filename = `${name}.${ext}`;
|
|
140
|
+
if (names.includes(filename)) {
|
|
141
|
+
return filename;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
var TableGuesser = class TableGuesser2 {
|
|
149
|
+
static {
|
|
150
|
+
__name(this, "TableGuesser");
|
|
151
|
+
}
|
|
152
|
+
static CREATE_PATTERNS = [
|
|
153
|
+
/^create_(\w+)_table$/,
|
|
154
|
+
/^create_(\w+)$/
|
|
155
|
+
];
|
|
156
|
+
static CHANGE_PATTERNS = [
|
|
157
|
+
/.+_(to|from|in)_(\w+)_table$/,
|
|
158
|
+
/.+_(to|from|in)_(\w+)$/
|
|
159
|
+
];
|
|
160
|
+
static guess(migration) {
|
|
161
|
+
for (const pattern of TableGuesser2.CREATE_PATTERNS) {
|
|
162
|
+
const matches = migration.match(pattern);
|
|
163
|
+
if (matches) {
|
|
164
|
+
return [
|
|
165
|
+
matches[1],
|
|
166
|
+
true
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
for (const pattern of TableGuesser2.CHANGE_PATTERNS) {
|
|
171
|
+
const matches = migration.match(pattern);
|
|
172
|
+
if (matches) {
|
|
173
|
+
return [
|
|
174
|
+
matches[2],
|
|
175
|
+
false
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export {
|
|
184
|
+
Utils,
|
|
185
|
+
TableGuesser
|
|
186
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Musket
|
|
3
|
+
} from "./chunk-KCJKQP37.js";
|
|
4
|
+
import {
|
|
5
|
+
Utils
|
|
6
|
+
} from "./chunk-POF4JGTX.js";
|
|
7
|
+
import {
|
|
8
|
+
__name
|
|
9
|
+
} from "./chunk-SHUYVCID.js";
|
|
10
|
+
|
|
11
|
+
// src/Kernel.ts
|
|
12
|
+
import { mkdir } from "fs/promises";
|
|
13
|
+
import path from "path";
|
|
14
|
+
var Kernel = class _Kernel {
|
|
15
|
+
static {
|
|
16
|
+
__name(this, "Kernel");
|
|
17
|
+
}
|
|
18
|
+
app;
|
|
19
|
+
cwd;
|
|
20
|
+
output = Utils.output();
|
|
21
|
+
basePath = "";
|
|
22
|
+
modulePath;
|
|
23
|
+
consolePath;
|
|
24
|
+
modulePackage;
|
|
25
|
+
consolePackage;
|
|
26
|
+
constructor(app, basePath) {
|
|
27
|
+
this.app = app;
|
|
28
|
+
}
|
|
29
|
+
static init(app) {
|
|
30
|
+
const instance = new _Kernel(app);
|
|
31
|
+
Promise.all([
|
|
32
|
+
instance.loadRequirements()
|
|
33
|
+
]).then(([e]) => e.run());
|
|
34
|
+
}
|
|
35
|
+
async run() {
|
|
36
|
+
await Musket.parse(this);
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
async ensureDirectoryExists(dir) {
|
|
40
|
+
await mkdir(dir, {
|
|
41
|
+
recursive: true
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async loadRequirements() {
|
|
45
|
+
this.cwd = path.join(process.cwd(), this.basePath);
|
|
46
|
+
this.modulePath = Utils.findModulePkg("@h3ravel/core", this.cwd) ?? "";
|
|
47
|
+
this.consolePath = Utils.findModulePkg("@h3ravel/console", this.cwd) ?? "";
|
|
48
|
+
try {
|
|
49
|
+
this.modulePackage = await import(path.join(this.modulePath, "package.json"));
|
|
50
|
+
} catch {
|
|
51
|
+
this.modulePackage = {
|
|
52
|
+
version: "N/A"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
this.consolePackage = await import(path.join(this.consolePath, "package.json"));
|
|
57
|
+
} catch {
|
|
58
|
+
this.consolePackage = {
|
|
59
|
+
version: "N/A"
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
Kernel
|
|
68
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-CCEWV2BR.js";
|
|
4
|
+
|
|
5
|
+
// src/Signature.ts
|
|
6
|
+
var Signature = class _Signature {
|
|
7
|
+
static {
|
|
8
|
+
__name(this, "Signature");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Helper to parse options inside a block of text
|
|
12
|
+
*
|
|
13
|
+
* @param block
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
static parseOptions(block) {
|
|
17
|
+
const options = [];
|
|
18
|
+
const regex = /\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g;
|
|
19
|
+
let match;
|
|
20
|
+
while ((match = regex.exec(block)) !== null) {
|
|
21
|
+
const shared = "^" === match[1][0] || /:[#^]/.test(match[1]);
|
|
22
|
+
const isHidden = ([
|
|
23
|
+
"#",
|
|
24
|
+
"^"
|
|
25
|
+
].includes(match[1][0]) || /:[#^]/.test(match[1])) && !shared;
|
|
26
|
+
const content = match[1].trim().replace(/[#^]/, "");
|
|
27
|
+
const colonIndex = content.indexOf(":");
|
|
28
|
+
if (colonIndex === -1) {
|
|
29
|
+
options.push({
|
|
30
|
+
name: content
|
|
31
|
+
});
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const namePart = content.substring(0, colonIndex).trim();
|
|
35
|
+
let rest = content.substring(colonIndex + 1).trim();
|
|
36
|
+
let description = rest;
|
|
37
|
+
let nestedOptions;
|
|
38
|
+
const pipeIndex = rest.indexOf("|");
|
|
39
|
+
if (pipeIndex !== -1) {
|
|
40
|
+
description = rest.substring(0, pipeIndex).trim();
|
|
41
|
+
const nestedText = rest.substring(pipeIndex + 1).trim();
|
|
42
|
+
const cleanedNestedText = nestedText.replace(/^\{/, "").trim();
|
|
43
|
+
nestedOptions = _Signature.parseOptions("{" + cleanedNestedText + "}");
|
|
44
|
+
} else {
|
|
45
|
+
description = description.trim();
|
|
46
|
+
}
|
|
47
|
+
let name = namePart;
|
|
48
|
+
let required = /[^a-zA-Z0-9_|-]/.test(name);
|
|
49
|
+
let multiple = false;
|
|
50
|
+
if (name.endsWith("?*")) {
|
|
51
|
+
required = false;
|
|
52
|
+
multiple = true;
|
|
53
|
+
name = name.slice(0, -2);
|
|
54
|
+
} else if (name.endsWith("*")) {
|
|
55
|
+
multiple = true;
|
|
56
|
+
name = name.slice(0, -1);
|
|
57
|
+
} else if (name.endsWith("?")) {
|
|
58
|
+
required = false;
|
|
59
|
+
name = name.slice(0, -1);
|
|
60
|
+
}
|
|
61
|
+
const isFlag = name.startsWith("--");
|
|
62
|
+
let flags;
|
|
63
|
+
let defaultValue;
|
|
64
|
+
if (isFlag) {
|
|
65
|
+
const flagParts = name.split("|").map((s) => s.trim());
|
|
66
|
+
flags = [];
|
|
67
|
+
for (let part of flagParts) {
|
|
68
|
+
if (part.startsWith("--") && part.slice(2).length === 1) {
|
|
69
|
+
part = "-" + part.slice(2);
|
|
70
|
+
} else if (part.startsWith("-") && !part.startsWith("--") && part.slice(1).length > 1) {
|
|
71
|
+
part = "--" + part.slice(1);
|
|
72
|
+
} else if (!part.startsWith("-") && part.slice(1).length > 1) {
|
|
73
|
+
part = "--" + part;
|
|
74
|
+
}
|
|
75
|
+
const eqIndex = part.indexOf("=");
|
|
76
|
+
if (eqIndex !== -1) {
|
|
77
|
+
flags.push(part.substring(0, eqIndex));
|
|
78
|
+
const val = part.substring(eqIndex + 1);
|
|
79
|
+
if (val === "*") {
|
|
80
|
+
defaultValue = [];
|
|
81
|
+
} else if (val === "true" || val === "false" || !val && !required) {
|
|
82
|
+
defaultValue = val === "true";
|
|
83
|
+
} else if (!isNaN(Number(val))) {
|
|
84
|
+
defaultValue = Number(val);
|
|
85
|
+
} else {
|
|
86
|
+
defaultValue = val;
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
flags.push(part);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
options.push({
|
|
94
|
+
name: isFlag ? flags[flags.length - 1] : name,
|
|
95
|
+
required,
|
|
96
|
+
multiple,
|
|
97
|
+
description,
|
|
98
|
+
flags,
|
|
99
|
+
shared,
|
|
100
|
+
isFlag,
|
|
101
|
+
isHidden,
|
|
102
|
+
defaultValue,
|
|
103
|
+
nestedOptions
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return options;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Helper to parse a command's signature
|
|
110
|
+
*
|
|
111
|
+
* @param signature
|
|
112
|
+
* @param commandClass
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
static parseSignature(signature, commandClass) {
|
|
116
|
+
const lines = signature.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
117
|
+
const isHidden = [
|
|
118
|
+
"#",
|
|
119
|
+
"^"
|
|
120
|
+
].includes(lines[0][0]) || /:[#^]/.test(lines[0]);
|
|
121
|
+
const baseCommand = lines[0].replace(/[^\w=:-]/g, "");
|
|
122
|
+
const description = commandClass.getDescription();
|
|
123
|
+
const isNamespaceCommand = baseCommand.endsWith(":");
|
|
124
|
+
const rest = lines.slice(1).join(" ");
|
|
125
|
+
const allOptions = _Signature.parseOptions(rest);
|
|
126
|
+
if (isNamespaceCommand) {
|
|
127
|
+
return {
|
|
128
|
+
baseCommand: baseCommand.slice(0, -1),
|
|
129
|
+
isNamespaceCommand,
|
|
130
|
+
subCommands: allOptions.filter((e) => !e.flags && !e.isHidden),
|
|
131
|
+
description,
|
|
132
|
+
commandClass,
|
|
133
|
+
options: allOptions.filter((e) => !!e.flags),
|
|
134
|
+
isHidden
|
|
135
|
+
};
|
|
136
|
+
} else {
|
|
137
|
+
return {
|
|
138
|
+
baseCommand,
|
|
139
|
+
isNamespaceCommand,
|
|
140
|
+
options: allOptions,
|
|
141
|
+
description,
|
|
142
|
+
commandClass,
|
|
143
|
+
isHidden
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export {
|
|
150
|
+
Signature
|
|
151
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-CCEWV2BR.js";
|
|
4
|
+
|
|
5
|
+
// src/Commands/Command.ts
|
|
6
|
+
var Command = class {
|
|
7
|
+
static {
|
|
8
|
+
__name(this, "Command");
|
|
9
|
+
}
|
|
10
|
+
app;
|
|
11
|
+
kernel;
|
|
12
|
+
constructor(app, kernel) {
|
|
13
|
+
this.app = app;
|
|
14
|
+
this.kernel = kernel;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The name and signature of the console command.
|
|
18
|
+
*
|
|
19
|
+
* @var string
|
|
20
|
+
*/
|
|
21
|
+
signature;
|
|
22
|
+
/**
|
|
23
|
+
* A dictionary of signatures or what not.
|
|
24
|
+
*
|
|
25
|
+
* @var object
|
|
26
|
+
*/
|
|
27
|
+
dictionary = {};
|
|
28
|
+
/**
|
|
29
|
+
* The console command description.
|
|
30
|
+
*
|
|
31
|
+
* @var string
|
|
32
|
+
*/
|
|
33
|
+
description;
|
|
34
|
+
/**
|
|
35
|
+
* The console command input.
|
|
36
|
+
*
|
|
37
|
+
* @var object
|
|
38
|
+
*/
|
|
39
|
+
input = {
|
|
40
|
+
options: {},
|
|
41
|
+
arguments: {}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Execute the console command.
|
|
45
|
+
*/
|
|
46
|
+
async handle(..._args) {
|
|
47
|
+
}
|
|
48
|
+
setApplication(app) {
|
|
49
|
+
this.app = app;
|
|
50
|
+
}
|
|
51
|
+
setInput(options, args, regArgs, dictionary) {
|
|
52
|
+
this.dictionary = dictionary;
|
|
53
|
+
this.input.options = options;
|
|
54
|
+
this.input.arguments = regArgs.map((e, i) => ({
|
|
55
|
+
[e.name()]: args[i]
|
|
56
|
+
})).reduce((e, x) => Object.assign(e, x), {});
|
|
57
|
+
}
|
|
58
|
+
getSignature() {
|
|
59
|
+
return this.signature;
|
|
60
|
+
}
|
|
61
|
+
getDescription() {
|
|
62
|
+
return this.description;
|
|
63
|
+
}
|
|
64
|
+
option(key, def) {
|
|
65
|
+
return this.input.options[key] ?? def;
|
|
66
|
+
}
|
|
67
|
+
options(key) {
|
|
68
|
+
if (key) {
|
|
69
|
+
return this.input.options[key];
|
|
70
|
+
}
|
|
71
|
+
return this.input.options;
|
|
72
|
+
}
|
|
73
|
+
argument(key, def) {
|
|
74
|
+
return this.input.arguments[key] ?? def;
|
|
75
|
+
}
|
|
76
|
+
arguments() {
|
|
77
|
+
return this.input.arguments;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
Command
|
|
83
|
+
};
|