convoker 0.3.0 → 0.3.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/dist/color.d.ts +153 -200
- package/dist/color.js +142 -48
- package/dist/command.d.ts +218 -555
- package/dist/command.js +513 -448
- package/dist/error.d.ts +107 -864
- package/dist/error.js +100 -10
- package/dist/index.d.ts +6 -1224
- package/dist/index.js +6 -13
- package/dist/input.d.ts +182 -252
- package/dist/input.js +185 -10
- package/dist/log.d.ts +61 -0
- package/dist/log.js +216 -0
- package/dist/{prompt.d.ts → prompt/index.d.ts} +193 -258
- package/dist/prompt/index.js +273 -0
- package/dist/prompt/raw.js +105 -9
- package/dist/standard-schema.d.ts +62 -0
- package/dist/standard-schema.js +16 -0
- package/dist/utils.d.ts +30 -0
- package/dist/utils.js +56 -0
- package/package.json +15 -12
- package/dist/chunks/__vite-browser-external-DQYBmsno.js +0 -80
- package/dist/chunks/color-CiruG_zQ.js +0 -153
- package/dist/chunks/error-CyKscMUD.js +0 -95
- package/dist/chunks/index-BluQjWvw.js +0 -198
- package/dist/chunks/input-WNu16aNE.js +0 -138
- package/dist/chunks/standard-schema-BHKzvwIS.js +0 -12
- package/dist/chunks/utils-DdmSEjLc.js +0 -22
- package/dist/prompt.js +0 -17
- package/dist/raw.d.ts +0 -38
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { i as c } from "./utils-DdmSEjLc.js";
|
|
2
|
-
async function d(e = "", t, u) {
|
|
3
|
-
if (c) {
|
|
4
|
-
await Deno.stdout.write(new TextEncoder().encode(e));
|
|
5
|
-
const a = new TextDecoder(), i = new Uint8Array(1024);
|
|
6
|
-
let n = "";
|
|
7
|
-
for (; ; ) {
|
|
8
|
-
const o = await Deno.stdin.read(i);
|
|
9
|
-
if (!o) break;
|
|
10
|
-
const s = a.decode(i.subarray(0, o));
|
|
11
|
-
if (s.includes(`
|
|
12
|
-
`)) {
|
|
13
|
-
n += s.split(`
|
|
14
|
-
`)[0];
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
n += s;
|
|
18
|
-
}
|
|
19
|
-
return n.trim() || t || "";
|
|
20
|
-
}
|
|
21
|
-
const r = await Promise.resolve().then(() => x);
|
|
22
|
-
return new Promise((a) => {
|
|
23
|
-
const i = r.createInterface({
|
|
24
|
-
input: process.stdin,
|
|
25
|
-
output: process.stdout,
|
|
26
|
-
terminal: !0
|
|
27
|
-
});
|
|
28
|
-
if (u?.masked) {
|
|
29
|
-
const n = i._writeToOutput.bind(i);
|
|
30
|
-
i._writeToOutput = (o) => {
|
|
31
|
-
if (o.match(/^\x1b/) || o.endsWith(`
|
|
32
|
-
`) || o.endsWith("\r")) return n(o);
|
|
33
|
-
const s = u.maskChar ?? "*";
|
|
34
|
-
n(s.repeat(o.length));
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
i.question(e, (n) => {
|
|
38
|
-
i.close(), a(n || t || "");
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
async function f() {
|
|
43
|
-
return new Promise((e) => {
|
|
44
|
-
const t = process.stdin;
|
|
45
|
-
t.setRawMode(!0), t.resume(), t.once("data", (u) => {
|
|
46
|
-
const r = u.toString();
|
|
47
|
-
return t.setRawMode(!1), t.pause(), e(r === "\r" || r === `
|
|
48
|
-
` ? "enter" : r === " " ? "space" : r === "\x1B[A" ? "up" : r === "\x1B[B" ? "down" : r === "\x1B[C" ? "right" : r === "\x1B[D" ? "left" : r);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function p(e = 1) {
|
|
53
|
-
for (let t = 0; t < e; t++) process.stdout.write("\x1B[2K\x1B[1A");
|
|
54
|
-
process.stdout.write("\x1B[2K\r");
|
|
55
|
-
}
|
|
56
|
-
function w(e = 1) {
|
|
57
|
-
process.stdout.write(`\x1B[${e}A`);
|
|
58
|
-
}
|
|
59
|
-
function l(e = 1) {
|
|
60
|
-
process.stdout.write(`\x1B[${e}B`);
|
|
61
|
-
}
|
|
62
|
-
const m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
63
|
-
__proto__: null,
|
|
64
|
-
clearLines: p,
|
|
65
|
-
cursorDown: l,
|
|
66
|
-
cursorUp: w,
|
|
67
|
-
readKey: f,
|
|
68
|
-
readLine: d
|
|
69
|
-
}, Symbol.toStringTag, { value: "Module" })), x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
70
|
-
__proto__: null
|
|
71
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
72
|
-
export {
|
|
73
|
-
x as _,
|
|
74
|
-
f as a,
|
|
75
|
-
w as b,
|
|
76
|
-
p as c,
|
|
77
|
-
m as d,
|
|
78
|
-
l as e,
|
|
79
|
-
d as r
|
|
80
|
-
};
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { m as p } from "./utils-DdmSEjLc.js";
|
|
2
|
-
function m() {
|
|
3
|
-
if (typeof window < "u" && typeof window.document < "u")
|
|
4
|
-
return !1;
|
|
5
|
-
const e = typeof process < "u" ? process.env ?? {} : {};
|
|
6
|
-
if ("NO_COLOR" in e) return !1;
|
|
7
|
-
if ("FORCE_COLOR" in e) return !0;
|
|
8
|
-
if ("CI" in e)
|
|
9
|
-
return !!([
|
|
10
|
-
"TRAVIS",
|
|
11
|
-
"CIRCLECI",
|
|
12
|
-
"APPVEYOR",
|
|
13
|
-
"GITLAB_CI",
|
|
14
|
-
"GITHUB_ACTIONS",
|
|
15
|
-
"BUILDKITE",
|
|
16
|
-
"DRONE"
|
|
17
|
-
].some((t) => t in e) || e.CI_NAME === "codeship");
|
|
18
|
-
if (typeof Deno < "u" && Deno.noColor !== void 0)
|
|
19
|
-
return !Deno.noColor;
|
|
20
|
-
if (typeof process < "u" && process.stdout) {
|
|
21
|
-
const t = e.TERM || "";
|
|
22
|
-
return (e.COLORTERM || "").length > 0 ? !0 : t === "dumb" ? !1 : /(color|ansi|cygwin|xterm|vt100)/i.test(t);
|
|
23
|
-
}
|
|
24
|
-
return !1;
|
|
25
|
-
}
|
|
26
|
-
const c = m();
|
|
27
|
-
function s(e, t) {
|
|
28
|
-
const n = `\x1B[${e}m`, r = `\x1B[${t}m`;
|
|
29
|
-
return c ? (o) => {
|
|
30
|
-
if (!o) return n + r;
|
|
31
|
-
const B = (o + "").replace(
|
|
32
|
-
new RegExp(`\x1B\\[${t}m`, "g"),
|
|
33
|
-
r + n
|
|
34
|
-
);
|
|
35
|
-
return n + B + r;
|
|
36
|
-
} : (o) => o + "";
|
|
37
|
-
}
|
|
38
|
-
const y = s(0, 0), a = s(1, 22), C = s(2, 22), i = s(3, 23), g = s(4, 24), w = s(53, 55), O = s(7, 27), R = s(8, 28), E = s(9, 29), I = s(30, 39), l = s(31, 39), u = s(32, 39), d = s(33, 39), T = s(34, 39), _ = s(35, 39), f = s(36, 39), v = s(37, 39), b = s(90, 39), A = s(40, 49), L = s(41, 49), M = s(42, 49), x = s(43, 49), D = s(44, 49), G = s(45, 49), S = s(46, 49), N = s(47, 49), k = s(100, 49), P = s(91, 39), j = s(92, 39), F = s(93, 39), H = s(94, 39), U = s(95, 39), Y = s(96, 39), $ = s(97, 39), z = s(101, 49), K = s(102, 49), V = s(103, 49), W = s(104, 49), q = s(105, 49), J = s(106, 49), Q = s(107, 49), h = {
|
|
39
|
-
primary: f,
|
|
40
|
-
secondary: b,
|
|
41
|
-
success: u,
|
|
42
|
-
warning: d,
|
|
43
|
-
error: l,
|
|
44
|
-
symbols: {
|
|
45
|
-
success: "✔",
|
|
46
|
-
error: "✖",
|
|
47
|
-
warning: "⚠"
|
|
48
|
-
},
|
|
49
|
-
styles: {
|
|
50
|
-
bold: a,
|
|
51
|
-
italic: i,
|
|
52
|
-
underline: g
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
function X(e) {
|
|
56
|
-
return p(h, e);
|
|
57
|
-
}
|
|
58
|
-
const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
59
|
-
__proto__: null,
|
|
60
|
-
DEFAULT_THEME: h,
|
|
61
|
-
bgBlack: A,
|
|
62
|
-
bgBlue: D,
|
|
63
|
-
bgBlueBright: W,
|
|
64
|
-
bgCyan: S,
|
|
65
|
-
bgCyanBright: J,
|
|
66
|
-
bgGray: k,
|
|
67
|
-
bgGreen: M,
|
|
68
|
-
bgGreenBright: K,
|
|
69
|
-
bgMagenta: G,
|
|
70
|
-
bgMagentaBright: q,
|
|
71
|
-
bgRed: L,
|
|
72
|
-
bgRedBright: z,
|
|
73
|
-
bgWhite: N,
|
|
74
|
-
bgWhiteBright: Q,
|
|
75
|
-
bgYellow: x,
|
|
76
|
-
bgYellowBright: V,
|
|
77
|
-
black: I,
|
|
78
|
-
blue: T,
|
|
79
|
-
blueBright: H,
|
|
80
|
-
bold: a,
|
|
81
|
-
createAnsiColor: s,
|
|
82
|
-
cyan: f,
|
|
83
|
-
cyanBright: Y,
|
|
84
|
-
defineTheme: X,
|
|
85
|
-
dim: C,
|
|
86
|
-
gray: b,
|
|
87
|
-
green: u,
|
|
88
|
-
greenBright: j,
|
|
89
|
-
hidden: R,
|
|
90
|
-
inverse: O,
|
|
91
|
-
italic: i,
|
|
92
|
-
magenta: _,
|
|
93
|
-
magentaBright: U,
|
|
94
|
-
overline: w,
|
|
95
|
-
red: l,
|
|
96
|
-
redBright: P,
|
|
97
|
-
reset: y,
|
|
98
|
-
strikethrough: E,
|
|
99
|
-
supportsColor: c,
|
|
100
|
-
underline: g,
|
|
101
|
-
white: v,
|
|
102
|
-
whiteBright: $,
|
|
103
|
-
yellow: d,
|
|
104
|
-
yellowBright: F
|
|
105
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
106
|
-
export {
|
|
107
|
-
G as A,
|
|
108
|
-
S as B,
|
|
109
|
-
N as C,
|
|
110
|
-
h as D,
|
|
111
|
-
k as E,
|
|
112
|
-
P as F,
|
|
113
|
-
j as G,
|
|
114
|
-
F as H,
|
|
115
|
-
H as I,
|
|
116
|
-
U as J,
|
|
117
|
-
Y as K,
|
|
118
|
-
$ as L,
|
|
119
|
-
z as M,
|
|
120
|
-
K as N,
|
|
121
|
-
V as O,
|
|
122
|
-
W as P,
|
|
123
|
-
q as Q,
|
|
124
|
-
J as R,
|
|
125
|
-
Q as S,
|
|
126
|
-
X as T,
|
|
127
|
-
es as a,
|
|
128
|
-
a as b,
|
|
129
|
-
f as c,
|
|
130
|
-
s as d,
|
|
131
|
-
C as e,
|
|
132
|
-
O as f,
|
|
133
|
-
b as g,
|
|
134
|
-
R as h,
|
|
135
|
-
i,
|
|
136
|
-
E as j,
|
|
137
|
-
I as k,
|
|
138
|
-
l,
|
|
139
|
-
u as m,
|
|
140
|
-
T as n,
|
|
141
|
-
w as o,
|
|
142
|
-
_ as p,
|
|
143
|
-
A as q,
|
|
144
|
-
y as r,
|
|
145
|
-
c as s,
|
|
146
|
-
L as t,
|
|
147
|
-
g as u,
|
|
148
|
-
M as v,
|
|
149
|
-
v as w,
|
|
150
|
-
x,
|
|
151
|
-
d as y,
|
|
152
|
-
D as z
|
|
153
|
-
};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
class n extends Error {
|
|
2
|
-
/**
|
|
3
|
-
* Creates a new input validation error.
|
|
4
|
-
* @param messages The messages.
|
|
5
|
-
*/
|
|
6
|
-
constructor(r) {
|
|
7
|
-
super(`Validation failed: ${r.join(", ")}`), this.messages = r;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
class o extends Error {
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new Convoker error.
|
|
13
|
-
* @param message The message.
|
|
14
|
-
* @param command The command.
|
|
15
|
-
*/
|
|
16
|
-
constructor(r, s) {
|
|
17
|
-
super(r), this.command = s;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Prints the error's message.
|
|
21
|
-
*/
|
|
22
|
-
print() {
|
|
23
|
-
console.error(this.message);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
class i extends o {
|
|
27
|
-
/**
|
|
28
|
-
* Creates a new help asked error.
|
|
29
|
-
* @param command The command.
|
|
30
|
-
*/
|
|
31
|
-
constructor(r) {
|
|
32
|
-
super("user asked for help!", r);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
class a extends o {
|
|
36
|
-
/**
|
|
37
|
-
* Creates a new too many arguments error.
|
|
38
|
-
* @param command The command.
|
|
39
|
-
*/
|
|
40
|
-
constructor(r) {
|
|
41
|
-
super("too many arguments!", r);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
class u extends o {
|
|
45
|
-
/**
|
|
46
|
-
* Creates a new unknown option error.
|
|
47
|
-
* @param command The command.
|
|
48
|
-
* @param key The key.
|
|
49
|
-
*/
|
|
50
|
-
constructor(r, s) {
|
|
51
|
-
super(`unknown option: ${s}!`, r), this.key = s;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
class c extends o {
|
|
55
|
-
/**
|
|
56
|
-
* Creates a new missing required option error.
|
|
57
|
-
* @param command The command.
|
|
58
|
-
* @param key The key.
|
|
59
|
-
* @param entry The entry.
|
|
60
|
-
*/
|
|
61
|
-
constructor(r, s, t) {
|
|
62
|
-
super(`missing required option: ${s}!`, r), this.key = s, this.entry = t;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
class d extends o {
|
|
66
|
-
/**
|
|
67
|
-
* Creates a new missing required argument error.
|
|
68
|
-
* @param command The command.
|
|
69
|
-
* @param key The key.
|
|
70
|
-
* @param entry The entry.
|
|
71
|
-
*/
|
|
72
|
-
constructor(r, s, t) {
|
|
73
|
-
super(`missing required positional argument: ${s}!`, r), this.key = s, this.entry = t;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
const l = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
77
|
-
__proto__: null,
|
|
78
|
-
ConvokerError: o,
|
|
79
|
-
HelpAskedError: i,
|
|
80
|
-
InputValidationError: n,
|
|
81
|
-
MissingRequiredArgumentError: d,
|
|
82
|
-
MissingRequiredOptionError: c,
|
|
83
|
-
TooManyArgumentsError: a,
|
|
84
|
-
UnknownOptionError: u
|
|
85
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
86
|
-
export {
|
|
87
|
-
o as C,
|
|
88
|
-
i as H,
|
|
89
|
-
n as I,
|
|
90
|
-
d as M,
|
|
91
|
-
a as T,
|
|
92
|
-
u as U,
|
|
93
|
-
c as a,
|
|
94
|
-
l as e
|
|
95
|
-
};
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { D as y } from "./color-CiruG_zQ.js";
|
|
2
|
-
import { v as p } from "./standard-schema-BHKzvwIS.js";
|
|
3
|
-
import { I as f } from "./error-CyKscMUD.js";
|
|
4
|
-
import { i as $, a as v, b } from "./utils-DdmSEjLc.js";
|
|
5
|
-
import { r as m, a as g, c as d, b as x, d as D } from "./__vite-browser-external-DQYBmsno.js";
|
|
6
|
-
let l = y;
|
|
7
|
-
function E(e) {
|
|
8
|
-
l = e;
|
|
9
|
-
}
|
|
10
|
-
async function L(e) {
|
|
11
|
-
const n = (e.theme ?? l).primary(e.message) + " ", t = await m(n, e.default);
|
|
12
|
-
if (e.minLength && t.length < e.minLength)
|
|
13
|
-
throw new f([
|
|
14
|
-
`Must be at least ${e.minLength} characters`
|
|
15
|
-
]);
|
|
16
|
-
if (e.maxLength && t.length > e.maxLength)
|
|
17
|
-
throw new f([
|
|
18
|
-
`Must be at most ${e.maxLength} characters`
|
|
19
|
-
]);
|
|
20
|
-
if (typeof e.validate == "function") {
|
|
21
|
-
if (!e.validate(t))
|
|
22
|
-
throw new f([
|
|
23
|
-
"Validation function returned a falsy value"
|
|
24
|
-
]);
|
|
25
|
-
} else e.validate && p(e.validate, t);
|
|
26
|
-
return t;
|
|
27
|
-
}
|
|
28
|
-
async function I(e) {
|
|
29
|
-
const a = e.theme ?? l, n = await m(a.primary(e.message) + " ", void 0, {
|
|
30
|
-
masked: !0,
|
|
31
|
-
maskChar: e.mask ?? "*"
|
|
32
|
-
});
|
|
33
|
-
if (e.confirm) {
|
|
34
|
-
const t = await m(
|
|
35
|
-
a.secondary("Confirm password: "),
|
|
36
|
-
void 0,
|
|
37
|
-
{
|
|
38
|
-
masked: !0,
|
|
39
|
-
maskChar: e.mask ?? "*"
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
if (n !== t) throw new Error(a.error("Passwords do not match"));
|
|
43
|
-
}
|
|
44
|
-
return n;
|
|
45
|
-
}
|
|
46
|
-
async function k(e) {
|
|
47
|
-
const a = e.theme ?? l, n = e.options;
|
|
48
|
-
let t = e.initialIndex ?? 0;
|
|
49
|
-
const i = () => {
|
|
50
|
-
d(n.length + 1), console.log(a.primary(e.message));
|
|
51
|
-
for (let s = 0; s < n.length; s++) {
|
|
52
|
-
const r = n[s], c = s === t ? a.accent?.("> ") ?? "> " : " ", o = r.disabled ? a.secondary(r.label) : a.foreground?.(r.label) ?? r.label;
|
|
53
|
-
console.log(c + o);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
for (console.log(a.primary(e.message)), n.forEach(
|
|
57
|
-
(s, r) => console.log(`${r === t ? "> " : " "}${s.label}`)
|
|
58
|
-
); ; ) {
|
|
59
|
-
const s = await g();
|
|
60
|
-
if (s === "up" && t > 0) t--;
|
|
61
|
-
else if (s === "down" && t < n.length - 1) t++;
|
|
62
|
-
else if (s === "enter") {
|
|
63
|
-
const r = n[t];
|
|
64
|
-
if (r.disabled) continue;
|
|
65
|
-
return d(n.length + 1), console.log(a.success(`${a.symbols?.success ?? "✔"} ${r.label}`)), r.value;
|
|
66
|
-
}
|
|
67
|
-
i();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async function T(e) {
|
|
71
|
-
const a = e.theme ?? l, n = e.options;
|
|
72
|
-
let t = e.initialIndex ?? 0;
|
|
73
|
-
const i = /* @__PURE__ */ new Set(), s = () => {
|
|
74
|
-
d(), console.log(a.primary(e.message)), n.forEach((r, c) => {
|
|
75
|
-
const o = c === t ? a.accent?.("> ") ?? "> " : " ", u = i.has(c) ? a.success("[x]") : "[ ]";
|
|
76
|
-
console.log(o + u + " " + r.label);
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
for (s(); ; ) {
|
|
80
|
-
const r = await g();
|
|
81
|
-
if (r === "up" && t > 0) t--;
|
|
82
|
-
else if (r === "down" && t < n.length - 1) t++;
|
|
83
|
-
else if (r === "space")
|
|
84
|
-
i.has(t) ? i.delete(t) : i.add(t);
|
|
85
|
-
else if (r === "return") {
|
|
86
|
-
const c = Array.from(i).map((o) => n[o].value);
|
|
87
|
-
return d(n.length + 1), console.log(a.success(`${e.message} ${c.length} selected`)), c;
|
|
88
|
-
}
|
|
89
|
-
x(n.length), s();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
async function _(e) {
|
|
93
|
-
const a = e.theme ?? l;
|
|
94
|
-
let n = "";
|
|
95
|
-
const t = e.filter ?? ((i, s) => s.label.toLowerCase().includes(i.toLowerCase()));
|
|
96
|
-
for (; ; ) {
|
|
97
|
-
d(), console.log(a.primary(e.message));
|
|
98
|
-
const i = e.options.filter((r) => t(n, r));
|
|
99
|
-
i.forEach(
|
|
100
|
-
(r) => console.log(" " + (a.foreground?.(r.label) ?? r.label))
|
|
101
|
-
);
|
|
102
|
-
const s = await m(a.secondary(`Search: ${n}`));
|
|
103
|
-
if (s !== "" && (n = s, i.length === 1))
|
|
104
|
-
return i[0].value;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async function C(e) {
|
|
108
|
-
const a = e.theme ?? l, n = e.yesLabel ?? "y", t = e.noLabel ?? "n", i = e.default ? n : t, s = await m(
|
|
109
|
-
`${a.primary(e.message)} ${a.secondary(`[${n}/${t}] (default: ${i})`)} `
|
|
110
|
-
);
|
|
111
|
-
return s ? /^y/i.test(s.trim()) : !!e.default;
|
|
112
|
-
}
|
|
113
|
-
async function F(e) {
|
|
114
|
-
const a = e.theme ?? {
|
|
115
|
-
primary: (n) => n,
|
|
116
|
-
secondary: (n) => n
|
|
117
|
-
};
|
|
118
|
-
console.log(a.primary(e.message ?? "Please enter text:")), console.log(a.secondary("Press Ctrl+D (or save & close editor) when done."));
|
|
119
|
-
try {
|
|
120
|
-
const n = await P(e.initial ?? "");
|
|
121
|
-
if (e.required && !n.trim()) throw new Error("Input required.");
|
|
122
|
-
return n;
|
|
123
|
-
} catch {
|
|
124
|
-
const n = await m("", e.initial, {});
|
|
125
|
-
if (e.required && !n.trim()) throw new Error("Input required.");
|
|
126
|
-
return n;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
async function P(e) {
|
|
130
|
-
const a = `edit-${Date.now()}.txt`;
|
|
131
|
-
if ($) {
|
|
132
|
-
const t = `${Deno.env.get("TMPDIR") ?? "/tmp"}/${a}`;
|
|
133
|
-
await Deno.writeTextFile(t, e ?? "");
|
|
134
|
-
const i = Deno.env.get("EDITOR") ?? "vi", r = await new Deno.Command(i, {
|
|
135
|
-
args: [t],
|
|
136
|
-
stdin: "inherit",
|
|
137
|
-
stdout: "inherit",
|
|
138
|
-
stderr: "inherit"
|
|
139
|
-
}).spawn().status;
|
|
140
|
-
if (!r.success)
|
|
141
|
-
throw new Error(`${i} exited with ${r.code}`);
|
|
142
|
-
const c = await Deno.readTextFile(t);
|
|
143
|
-
return await Deno.remove(t).catch(() => {
|
|
144
|
-
}), c;
|
|
145
|
-
}
|
|
146
|
-
if (v) {
|
|
147
|
-
const { $: n } = await import("bun"), t = `/tmp/${a}`;
|
|
148
|
-
await Bun.write(t, e ?? "");
|
|
149
|
-
const i = process.env.EDITOR ?? "vi";
|
|
150
|
-
await n`${i} ${t}`;
|
|
151
|
-
const s = await Bun.file(t).text();
|
|
152
|
-
return await Bun.write(t, ""), s;
|
|
153
|
-
}
|
|
154
|
-
if (b) {
|
|
155
|
-
const { tmpdir: n } = await import("./__vite-browser-external-DQYBmsno.js").then((o) => o._), { join: t } = await import("./__vite-browser-external-DQYBmsno.js").then((o) => o._), { promises: i } = await import("./__vite-browser-external-DQYBmsno.js").then((o) => o._), { spawn: s } = await import("./__vite-browser-external-DQYBmsno.js").then((o) => o._), r = t(n(), a);
|
|
156
|
-
await i.writeFile(r, e ?? "", "utf8");
|
|
157
|
-
const c = process.env.EDITOR || process.env.VISUAL || (process.platform === "win32" ? "notepad" : "vi");
|
|
158
|
-
return new Promise((o, u) => {
|
|
159
|
-
s(c, [r], { stdio: "inherit" }).on("exit", async (w) => {
|
|
160
|
-
if (w !== 0) {
|
|
161
|
-
u(new Error(`${c} exited with code ${w}`));
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
try {
|
|
165
|
-
const h = await i.readFile(r, "utf8");
|
|
166
|
-
await i.unlink(r).catch(() => {
|
|
167
|
-
}), o(h);
|
|
168
|
-
} catch (h) {
|
|
169
|
-
u(h);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
throw new Error("Unsupported runtime for system editor.");
|
|
175
|
-
}
|
|
176
|
-
const U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
177
|
-
__proto__: null,
|
|
178
|
-
confirm: C,
|
|
179
|
-
editor: F,
|
|
180
|
-
multiselect: T,
|
|
181
|
-
password: I,
|
|
182
|
-
raw: D,
|
|
183
|
-
search: _,
|
|
184
|
-
select: k,
|
|
185
|
-
setTheme: E,
|
|
186
|
-
text: L
|
|
187
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
188
|
-
export {
|
|
189
|
-
k as a,
|
|
190
|
-
_ as b,
|
|
191
|
-
C as c,
|
|
192
|
-
F as e,
|
|
193
|
-
U as i,
|
|
194
|
-
T as m,
|
|
195
|
-
I as p,
|
|
196
|
-
E as s,
|
|
197
|
-
L as t
|
|
198
|
-
};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { v as o } from "./standard-schema-BHKzvwIS.js";
|
|
2
|
-
async function a(r, t) {
|
|
3
|
-
async function i(e) {
|
|
4
|
-
if (typeof r == "string")
|
|
5
|
-
switch (r) {
|
|
6
|
-
case "boolean":
|
|
7
|
-
return e === "true";
|
|
8
|
-
case "bigint":
|
|
9
|
-
return BigInt(e);
|
|
10
|
-
case "number":
|
|
11
|
-
return parseFloat(e);
|
|
12
|
-
case "string":
|
|
13
|
-
return e;
|
|
14
|
-
}
|
|
15
|
-
return o(r, e);
|
|
16
|
-
}
|
|
17
|
-
return Array.isArray(t) ? await Promise.all(t.map((u) => i(u))) : i(t);
|
|
18
|
-
}
|
|
19
|
-
class n {
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new option.
|
|
22
|
-
* @param kind The type of this option.
|
|
23
|
-
* @param names The names of this option.
|
|
24
|
-
*/
|
|
25
|
-
constructor(t, i) {
|
|
26
|
-
this.$required = !0, this.$list = !1, this.$kind = t, this.$names = i.map((e) => e.replace(/^-+/, ""));
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Makes this option a list.
|
|
30
|
-
* @returns this
|
|
31
|
-
*/
|
|
32
|
-
list(t) {
|
|
33
|
-
return this.$list = !0, this.$separator = t ?? this.$separator, this;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Makes this option required.
|
|
37
|
-
* @returns this
|
|
38
|
-
*/
|
|
39
|
-
required() {
|
|
40
|
-
return this.$required = !0, this;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Makes this option optional.
|
|
44
|
-
* @returns this
|
|
45
|
-
*/
|
|
46
|
-
optional() {
|
|
47
|
-
return this.$required = !1, this;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Sets a default value.
|
|
51
|
-
* @param value The default value.
|
|
52
|
-
* @returns this
|
|
53
|
-
*/
|
|
54
|
-
default(t) {
|
|
55
|
-
return this.$default = t, this;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Sets a description.
|
|
59
|
-
* @param desc The description.
|
|
60
|
-
* @returns this
|
|
61
|
-
*/
|
|
62
|
-
description(t) {
|
|
63
|
-
return this.$description = t, this;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
class s {
|
|
67
|
-
/**
|
|
68
|
-
* Creates a new positional argument.
|
|
69
|
-
* @param kind The positional argument.
|
|
70
|
-
*/
|
|
71
|
-
constructor(t) {
|
|
72
|
-
this.$required = !0, this.$list = !1, this.$kind = t;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Makes this argument a list.
|
|
76
|
-
* @returns this
|
|
77
|
-
*/
|
|
78
|
-
list() {
|
|
79
|
-
return this.$list = !0, this;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Makes this argument required.
|
|
83
|
-
* @returns this
|
|
84
|
-
*/
|
|
85
|
-
required() {
|
|
86
|
-
return this.$required = !0, this;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Makes this argument optional.
|
|
90
|
-
* @returns this
|
|
91
|
-
*/
|
|
92
|
-
optional() {
|
|
93
|
-
return this.$required = !1, this;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Sets a default value.
|
|
97
|
-
* @param value The default value.
|
|
98
|
-
* @returns this
|
|
99
|
-
*/
|
|
100
|
-
default(t) {
|
|
101
|
-
return this.$default = t, this;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Sets a description.
|
|
105
|
-
* @param desc The description.
|
|
106
|
-
* @returns this
|
|
107
|
-
*/
|
|
108
|
-
description(t) {
|
|
109
|
-
return this.$description = t, this;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function c(r, ...t) {
|
|
113
|
-
return new n(r, t);
|
|
114
|
-
}
|
|
115
|
-
function h(r) {
|
|
116
|
-
return new s(r);
|
|
117
|
-
}
|
|
118
|
-
function l(r) {
|
|
119
|
-
return new s(r);
|
|
120
|
-
}
|
|
121
|
-
const d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
122
|
-
__proto__: null,
|
|
123
|
-
Option: n,
|
|
124
|
-
Positional: s,
|
|
125
|
-
argument: l,
|
|
126
|
-
convert: a,
|
|
127
|
-
option: c,
|
|
128
|
-
positional: h
|
|
129
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
130
|
-
export {
|
|
131
|
-
n as O,
|
|
132
|
-
s as P,
|
|
133
|
-
l as a,
|
|
134
|
-
a as c,
|
|
135
|
-
d as i,
|
|
136
|
-
c as o,
|
|
137
|
-
h as p
|
|
138
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const p = typeof process < "u" && process.versions != null && process.versions.node != null, d = typeof Deno < "u" && typeof Deno.version?.deno == "string", u = typeof Bun < "u" && typeof Bun.version == "string";
|
|
2
|
-
function r(e) {
|
|
3
|
-
return e !== null && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype;
|
|
4
|
-
}
|
|
5
|
-
function c(e, n) {
|
|
6
|
-
if (Array.isArray(e) && Array.isArray(n))
|
|
7
|
-
return n;
|
|
8
|
-
if (r(e) && r(n)) {
|
|
9
|
-
const s = {};
|
|
10
|
-
return (/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(n)])).forEach((o) => {
|
|
11
|
-
const i = e[o], t = n[o];
|
|
12
|
-
i !== void 0 && t !== void 0 ? s[o] = c(i, t) : t !== void 0 ? s[o] = t : s[o] = i;
|
|
13
|
-
}), s;
|
|
14
|
-
}
|
|
15
|
-
return n;
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
u as a,
|
|
19
|
-
p as b,
|
|
20
|
-
d as i,
|
|
21
|
-
c as m
|
|
22
|
-
};
|