@rhseung/ps-cli 1.3.3 → 1.4.0
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/chunk-7MQMPJ3X.js +88 -0
- package/dist/{chunk-PNIGP6LX.js → chunk-7SVCS23X.js} +392 -96
- package/dist/{chunk-2E4VSP6O.js → chunk-NB4OIWND.js} +139 -139
- package/dist/{chunk-EIFFWFLS.js → chunk-OJZLQ6FK.js} +1 -1
- package/dist/chunk-QGMWUOJ3.js +23 -0
- package/dist/commands/config.js +298 -262
- package/dist/commands/fetch.js +262 -254
- package/dist/commands/init.js +138 -101
- package/dist/commands/open.js +74 -78
- package/dist/commands/run.js +99 -98
- package/dist/commands/stats.js +71 -65
- package/dist/commands/submit.js +112 -126
- package/dist/commands/test.js +203 -203
- package/dist/index.js +7 -6
- package/package.json +16 -6
- package/dist/chunk-6ENX5K3C.js +0 -84
- package/dist/chunk-FYS2JH42.js +0 -31
- package/dist/chunk-TQXMB7XV.js +0 -52
package/dist/commands/config.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
3
|
+
Command,
|
|
4
|
+
CommandBuilder,
|
|
5
|
+
CommandDef,
|
|
7
6
|
getAutoOpenEditor,
|
|
8
7
|
getDefaultLanguage,
|
|
9
8
|
getEditor,
|
|
10
9
|
getProblemDir,
|
|
11
10
|
getSolvedAcHandle
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import
|
|
11
|
+
} from "../chunk-7SVCS23X.js";
|
|
12
|
+
import {
|
|
13
|
+
__decorateClass,
|
|
14
|
+
getSupportedLanguages,
|
|
15
|
+
getSupportedLanguagesString
|
|
16
|
+
} from "../chunk-7MQMPJ3X.js";
|
|
14
17
|
|
|
15
18
|
// src/commands/config.tsx
|
|
16
|
-
import React from "react";
|
|
17
|
-
import { render, Text, Box } from "ink";
|
|
18
19
|
import { StatusMessage, Select, TextInput, Alert } from "@inkjs/ui";
|
|
20
|
+
import { render, Text, Box } from "ink";
|
|
21
|
+
|
|
22
|
+
// src/hooks/use-config.ts
|
|
23
|
+
import { existsSync } from "fs";
|
|
19
24
|
import { readFile, writeFile, unlink } from "fs/promises";
|
|
20
25
|
import { join } from "path";
|
|
21
|
-
import {
|
|
22
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
+
import { useEffect, useState } from "react";
|
|
23
27
|
function getProjectConfigPath() {
|
|
24
28
|
return join(process.cwd(), ".ps-cli.json");
|
|
25
29
|
}
|
|
@@ -39,57 +43,19 @@ async function writeProjectConfig(config) {
|
|
|
39
43
|
const configPath = getProjectConfigPath();
|
|
40
44
|
await writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
41
45
|
}
|
|
42
|
-
function
|
|
43
|
-
return `
|
|
44
|
-
\uC0AC\uC6A9\uBC95:
|
|
45
|
-
$ ps config get [\uD0A4]
|
|
46
|
-
$ ps config set [\uD0A4]
|
|
47
|
-
$ ps config list
|
|
48
|
-
$ ps config clear
|
|
49
|
-
|
|
50
|
-
\uC124\uBA85:
|
|
51
|
-
\uD504\uB85C\uC81D\uD2B8 \uC124\uC815 \uD30C\uC77C(.ps-cli.json)\uC744 \uAD00\uB9AC\uD569\uB2C8\uB2E4.
|
|
52
|
-
\uC124\uC815\uC740 \uD604\uC7AC \uD504\uB85C\uC81D\uD2B8\uC758 .ps-cli.json \uD30C\uC77C\uC5D0 \uC800\uC7A5\uB429\uB2C8\uB2E4.
|
|
53
|
-
|
|
54
|
-
\uBA85\uB839\uC5B4:
|
|
55
|
-
get [\uD0A4] \uC124\uC815 \uAC12 \uC870\uD68C (\uD0A4 \uC5C6\uC73C\uBA74 \uB300\uD654\uD615 \uC120\uD0DD)
|
|
56
|
-
set [\uD0A4] \uC124\uC815 \uAC12 \uC124\uC815 (\uD0A4 \uC5C6\uC73C\uBA74 \uB300\uD654\uD615 \uC120\uD0DD)
|
|
57
|
-
list \uBAA8\uB4E0 \uC124\uC815 \uC870\uD68C
|
|
58
|
-
clear .ps-cli.json \uD30C\uC77C \uC0AD\uC81C
|
|
59
|
-
|
|
60
|
-
\uC124\uC815 \uD0A4:
|
|
61
|
-
default-language \uAE30\uBCF8 \uC5B8\uC5B4 (${getSupportedLanguagesString()})
|
|
62
|
-
editor \uC5D0\uB514\uD130 \uBA85\uB839\uC5B4 (\uC608: code, vim, nano)
|
|
63
|
-
auto-open-editor fetch \uD6C4 \uC790\uB3D9\uC73C\uB85C \uC5D0\uB514\uD130 \uC5F4\uAE30 (true/false)
|
|
64
|
-
solved-ac-handle Solved.ac \uD578\uB4E4 (stats \uBA85\uB839\uC5B4\uC6A9)
|
|
65
|
-
problem-dir \uBB38\uC81C \uB514\uB809\uD1A0\uB9AC \uACBD\uB85C (\uAE30\uBCF8\uAC12: problems, "." \uB610\uB294 ""\uB294 \uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8)
|
|
66
|
-
|
|
67
|
-
\uC635\uC158:
|
|
68
|
-
--help, -h \uB3C4\uC6C0\uB9D0 \uD45C\uC2DC
|
|
69
|
-
|
|
70
|
-
\uC608\uC81C:
|
|
71
|
-
$ ps config get # \uB300\uD654\uD615\uC73C\uB85C \uD0A4 \uC120\uD0DD \uD6C4 \uAC12 \uC870\uD68C
|
|
72
|
-
$ ps config get default-language # default-language \uAC12 \uC870\uD68C
|
|
73
|
-
$ ps config set # \uB300\uD654\uD615\uC73C\uB85C \uD0A4 \uC120\uD0DD \uD6C4 \uAC12 \uC124\uC815
|
|
74
|
-
$ ps config set editor cursor # editor\uB97C cursor\uB85C \uC124\uC815
|
|
75
|
-
$ ps config list # \uBAA8\uB4E0 \uC124\uC815 \uC870\uD68C
|
|
76
|
-
$ ps config clear # .ps-cli.json \uD30C\uC77C \uC0AD\uC81C
|
|
77
|
-
`;
|
|
78
|
-
}
|
|
79
|
-
var configHelp = getConfigHelp();
|
|
80
|
-
function ConfigCommand({
|
|
46
|
+
function useConfig({
|
|
81
47
|
configKey,
|
|
82
48
|
value,
|
|
83
|
-
get,
|
|
84
|
-
list,
|
|
49
|
+
get: _get,
|
|
50
|
+
list: _list,
|
|
85
51
|
clear,
|
|
86
|
-
onComplete
|
|
52
|
+
onComplete: _onComplete
|
|
87
53
|
}) {
|
|
88
|
-
const [config, setConfig] =
|
|
89
|
-
const [loading, setLoading] =
|
|
90
|
-
const [cleared, setCleared] =
|
|
91
|
-
const [saved, setSaved] =
|
|
92
|
-
|
|
54
|
+
const [config, setConfig] = useState(null);
|
|
55
|
+
const [loading, setLoading] = useState(true);
|
|
56
|
+
const [cleared, setCleared] = useState(false);
|
|
57
|
+
const [saved, setSaved] = useState(false);
|
|
58
|
+
useEffect(() => {
|
|
93
59
|
async function loadConfig() {
|
|
94
60
|
const projectConfig = await readProjectConfig();
|
|
95
61
|
setConfig(projectConfig);
|
|
@@ -97,7 +63,7 @@ function ConfigCommand({
|
|
|
97
63
|
}
|
|
98
64
|
void loadConfig();
|
|
99
65
|
}, []);
|
|
100
|
-
|
|
66
|
+
useEffect(() => {
|
|
101
67
|
if (clear && !cleared) {
|
|
102
68
|
void (async () => {
|
|
103
69
|
const configPath = getProjectConfigPath();
|
|
@@ -108,11 +74,11 @@ function ConfigCommand({
|
|
|
108
74
|
})();
|
|
109
75
|
}
|
|
110
76
|
}, [clear, cleared]);
|
|
111
|
-
|
|
77
|
+
useEffect(() => {
|
|
112
78
|
if (configKey && value !== void 0 && !saved) {
|
|
113
79
|
void (async () => {
|
|
114
80
|
const currentConfig = await readProjectConfig() ?? {};
|
|
115
|
-
|
|
81
|
+
const updatedConfig = { ...currentConfig };
|
|
116
82
|
switch (configKey) {
|
|
117
83
|
case "default-language": {
|
|
118
84
|
const supportedLanguages = getSupportedLanguages();
|
|
@@ -147,6 +113,77 @@ function ConfigCommand({
|
|
|
147
113
|
})();
|
|
148
114
|
}
|
|
149
115
|
}, [configKey, value, saved]);
|
|
116
|
+
return {
|
|
117
|
+
config,
|
|
118
|
+
loading,
|
|
119
|
+
cleared,
|
|
120
|
+
saved
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/commands/config.tsx
|
|
125
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
126
|
+
function getConfigHelp() {
|
|
127
|
+
return `
|
|
128
|
+
\uC0AC\uC6A9\uBC95:
|
|
129
|
+
$ ps config get [\uD0A4]
|
|
130
|
+
$ ps config set [\uD0A4]
|
|
131
|
+
$ ps config list
|
|
132
|
+
$ ps config clear
|
|
133
|
+
|
|
134
|
+
\uC124\uBA85:
|
|
135
|
+
\uD504\uB85C\uC81D\uD2B8 \uC124\uC815 \uD30C\uC77C(.ps-cli.json)\uC744 \uAD00\uB9AC\uD569\uB2C8\uB2E4.
|
|
136
|
+
\uC124\uC815\uC740 \uD604\uC7AC \uD504\uB85C\uC81D\uD2B8\uC758 .ps-cli.json \uD30C\uC77C\uC5D0 \uC800\uC7A5\uB429\uB2C8\uB2E4.
|
|
137
|
+
|
|
138
|
+
\uBA85\uB839\uC5B4:
|
|
139
|
+
get [\uD0A4] \uC124\uC815 \uAC12 \uC870\uD68C (\uD0A4 \uC5C6\uC73C\uBA74 \uB300\uD654\uD615 \uC120\uD0DD)
|
|
140
|
+
set [\uD0A4] \uC124\uC815 \uAC12 \uC124\uC815 (\uD0A4 \uC5C6\uC73C\uBA74 \uB300\uD654\uD615 \uC120\uD0DD)
|
|
141
|
+
list \uBAA8\uB4E0 \uC124\uC815 \uC870\uD68C
|
|
142
|
+
clear .ps-cli.json \uD30C\uC77C \uC0AD\uC81C
|
|
143
|
+
|
|
144
|
+
\uC124\uC815 \uD0A4:
|
|
145
|
+
default-language \uAE30\uBCF8 \uC5B8\uC5B4 (${getSupportedLanguagesString()})
|
|
146
|
+
editor \uC5D0\uB514\uD130 \uBA85\uB839\uC5B4 (\uC608: code, vim, nano)
|
|
147
|
+
auto-open-editor fetch \uD6C4 \uC790\uB3D9\uC73C\uB85C \uC5D0\uB514\uD130 \uC5F4\uAE30 (true/false)
|
|
148
|
+
solved-ac-handle Solved.ac \uD578\uB4E4 (stats \uBA85\uB839\uC5B4\uC6A9)
|
|
149
|
+
problem-dir \uBB38\uC81C \uB514\uB809\uD1A0\uB9AC \uACBD\uB85C (\uAE30\uBCF8\uAC12: problems, "." \uB610\uB294 ""\uB294 \uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8)
|
|
150
|
+
|
|
151
|
+
\uC635\uC158:
|
|
152
|
+
--help, -h \uB3C4\uC6C0\uB9D0 \uD45C\uC2DC
|
|
153
|
+
|
|
154
|
+
\uC608\uC81C:
|
|
155
|
+
$ ps config get # \uB300\uD654\uD615\uC73C\uB85C \uD0A4 \uC120\uD0DD \uD6C4 \uAC12 \uC870\uD68C
|
|
156
|
+
$ ps config get default-language # default-language \uAC12 \uC870\uD68C
|
|
157
|
+
$ ps config set # \uB300\uD654\uD615\uC73C\uB85C \uD0A4 \uC120\uD0DD \uD6C4 \uAC12 \uC124\uC815
|
|
158
|
+
$ ps config set editor cursor # editor\uB97C cursor\uB85C \uC124\uC815
|
|
159
|
+
$ ps config list # \uBAA8\uB4E0 \uC124\uC815 \uC870\uD68C
|
|
160
|
+
$ ps config clear # .ps-cli.json \uD30C\uC77C \uC0AD\uC81C
|
|
161
|
+
`;
|
|
162
|
+
}
|
|
163
|
+
var configHelp = getConfigHelp();
|
|
164
|
+
var CONFIG_KEYS = [
|
|
165
|
+
{ label: "default-language", value: "default-language" },
|
|
166
|
+
{ label: "editor", value: "editor" },
|
|
167
|
+
{ label: "auto-open-editor", value: "auto-open-editor" },
|
|
168
|
+
{ label: "solved-ac-handle", value: "solved-ac-handle" },
|
|
169
|
+
{ label: "problem-dir", value: "problem-dir" }
|
|
170
|
+
];
|
|
171
|
+
function ConfigView({
|
|
172
|
+
configKey,
|
|
173
|
+
value,
|
|
174
|
+
get,
|
|
175
|
+
list,
|
|
176
|
+
clear,
|
|
177
|
+
onComplete
|
|
178
|
+
}) {
|
|
179
|
+
const { config, loading, cleared, saved } = useConfig({
|
|
180
|
+
configKey,
|
|
181
|
+
value,
|
|
182
|
+
get,
|
|
183
|
+
list,
|
|
184
|
+
clear,
|
|
185
|
+
onComplete
|
|
186
|
+
});
|
|
150
187
|
if (loading) {
|
|
151
188
|
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(StatusMessage, { variant: "info", children: "\uC124\uC815\uC744 \uBD88\uB7EC\uC624\uB294 \uC911..." }) });
|
|
152
189
|
}
|
|
@@ -235,222 +272,221 @@ function ConfigCommand({
|
|
|
235
272
|
}
|
|
236
273
|
return null;
|
|
237
274
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
275
|
+
var ConfigCommand = class extends Command {
|
|
276
|
+
async execute(args, flags) {
|
|
277
|
+
const command = args[0];
|
|
278
|
+
if (command === "clear") {
|
|
279
|
+
await this.renderView(ConfigView, {
|
|
280
|
+
clear: true
|
|
281
|
+
});
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (command === "list" || flags.list) {
|
|
285
|
+
await this.renderView(ConfigView, {
|
|
286
|
+
list: true
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (command === "get") {
|
|
291
|
+
const key = args[1];
|
|
292
|
+
if (key) {
|
|
293
|
+
await this.renderView(ConfigView, {
|
|
294
|
+
configKey: key,
|
|
295
|
+
get: true
|
|
296
|
+
});
|
|
297
|
+
} else {
|
|
298
|
+
const selectedKey = await this.selectConfigKey();
|
|
299
|
+
if (!selectedKey) {
|
|
300
|
+
process.exit(0);
|
|
301
|
+
return;
|
|
253
302
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
];
|
|
269
|
-
function ConfigKeySelector({ onSelect }) {
|
|
270
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
271
|
-
/* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { color: "cyan", bold: true, children: "\u2699\uFE0F \uC124\uC815 \uAD00\uB9AC" }) }),
|
|
272
|
-
/* @__PURE__ */ jsx(Alert, { variant: "info", children: "\uC124\uC815 \uD0A4\uB97C \uC120\uD0DD\uD558\uC138\uC694" }),
|
|
273
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
|
|
274
|
-
Select,
|
|
275
|
-
{
|
|
276
|
-
options: CONFIG_KEYS,
|
|
277
|
-
onChange: (value) => {
|
|
278
|
-
onSelect(value);
|
|
303
|
+
await this.renderView(ConfigView, {
|
|
304
|
+
configKey: selectedKey,
|
|
305
|
+
get: true
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (command === "set") {
|
|
311
|
+
const key = args[1];
|
|
312
|
+
if (key) {
|
|
313
|
+
const inputValue = await this.inputConfigValue(key);
|
|
314
|
+
if (!inputValue) {
|
|
315
|
+
process.exit(0);
|
|
316
|
+
return;
|
|
279
317
|
}
|
|
318
|
+
await this.renderView(ConfigView, {
|
|
319
|
+
configKey: key,
|
|
320
|
+
value: inputValue
|
|
321
|
+
});
|
|
322
|
+
} else {
|
|
323
|
+
const selectedKey = await this.selectConfigKey();
|
|
324
|
+
if (!selectedKey) {
|
|
325
|
+
process.exit(0);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const inputValue = await this.inputConfigValue(selectedKey);
|
|
329
|
+
if (!inputValue) {
|
|
330
|
+
process.exit(0);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
await this.renderView(ConfigView, {
|
|
334
|
+
configKey: selectedKey,
|
|
335
|
+
value: inputValue
|
|
336
|
+
});
|
|
280
337
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (!command) {
|
|
341
|
+
console.error("\uC624\uB958: \uBA85\uB839\uC5B4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.");
|
|
342
|
+
console.error("\uC0AC\uC6A9\uBC95: ps config <\uBA85\uB839\uC5B4>");
|
|
343
|
+
console.error("\uBA85\uB839\uC5B4: get, set, list, clear");
|
|
344
|
+
console.error("\uB3C4\uC6C0\uB9D0: ps config --help");
|
|
345
|
+
process.exit(1);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
console.error(`\uC624\uB958: \uC54C \uC218 \uC5C6\uB294 \uBA85\uB839\uC5B4: ${command}`);
|
|
349
|
+
console.error("\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uBA85\uB839\uC5B4: get, set, list, clear");
|
|
350
|
+
console.error("\uB3C4\uC6C0\uB9D0: ps config --help");
|
|
351
|
+
process.exit(1);
|
|
352
|
+
}
|
|
353
|
+
// 설정 키 선택: private 메서드
|
|
354
|
+
async selectConfigKey() {
|
|
355
|
+
return new Promise((resolve) => {
|
|
356
|
+
const { unmount } = render(
|
|
357
|
+
/* @__PURE__ */ jsx(
|
|
358
|
+
this.ConfigKeySelector,
|
|
359
|
+
{
|
|
360
|
+
onSelect: (key) => {
|
|
361
|
+
unmount();
|
|
362
|
+
resolve(key);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
)
|
|
366
|
+
);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
// 설정 값 입력: private 메서드
|
|
370
|
+
async inputConfigValue(configKey) {
|
|
371
|
+
return new Promise((resolve) => {
|
|
372
|
+
const { unmount } = render(
|
|
373
|
+
/* @__PURE__ */ jsx(
|
|
374
|
+
this.ConfigValueInput,
|
|
375
|
+
{
|
|
376
|
+
configKey,
|
|
377
|
+
onSubmit: (value) => {
|
|
378
|
+
unmount();
|
|
379
|
+
resolve(value);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
// 설정 키 선택 컴포넌트: 클래스 내부에 정의
|
|
387
|
+
ConfigKeySelector = ({
|
|
388
|
+
onSelect
|
|
389
|
+
}) => {
|
|
390
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
391
|
+
/* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { color: "cyan", bold: true, children: "\u2699\uFE0F \uC124\uC815 \uAD00\uB9AC" }) }),
|
|
392
|
+
/* @__PURE__ */ jsx(Alert, { variant: "info", children: "\uC124\uC815 \uD0A4\uB97C \uC120\uD0DD\uD558\uC138\uC694" }),
|
|
393
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
|
|
394
|
+
Select,
|
|
289
395
|
{
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
396
|
+
options: CONFIG_KEYS,
|
|
397
|
+
onChange: (value) => {
|
|
398
|
+
onSelect(value);
|
|
293
399
|
}
|
|
294
400
|
}
|
|
295
|
-
)
|
|
296
|
-
);
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
function ConfigValueInput({
|
|
300
|
-
configKey,
|
|
301
|
-
onSubmit
|
|
302
|
-
}) {
|
|
303
|
-
const getPlaceholder = () => {
|
|
304
|
-
switch (configKey) {
|
|
305
|
-
case "default-language":
|
|
306
|
-
return `\uC5B8\uC5B4 \uC785\uB825 (${getSupportedLanguagesString()})`;
|
|
307
|
-
case "editor":
|
|
308
|
-
return "\uC5D0\uB514\uD130 \uBA85\uB839\uC5B4 \uC785\uB825";
|
|
309
|
-
case "auto-open-editor":
|
|
310
|
-
return "true \uB610\uB294 false \uC785\uB825";
|
|
311
|
-
case "solved-ac-handle":
|
|
312
|
-
return "Solved.ac \uD578\uB4E4 \uC785\uB825";
|
|
313
|
-
case "problem-dir":
|
|
314
|
-
return "\uBB38\uC81C \uB514\uB809\uD1A0\uB9AC \uACBD\uB85C \uC785\uB825";
|
|
315
|
-
default:
|
|
316
|
-
return "\uAC12 \uC785\uB825";
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
const getDescription = () => {
|
|
320
|
-
switch (configKey) {
|
|
321
|
-
case "default-language":
|
|
322
|
-
return `\uC9C0\uC6D0 \uC5B8\uC5B4: ${getSupportedLanguagesString()}`;
|
|
323
|
-
case "editor":
|
|
324
|
-
return "\uC608: code, cursor, vim, nano";
|
|
325
|
-
case "auto-open-editor":
|
|
326
|
-
return "fetch \uD6C4 \uC790\uB3D9\uC73C\uB85C \uC5D0\uB514\uD130\uB97C \uC5F4\uC9C0 \uC5EC\uBD80";
|
|
327
|
-
case "solved-ac-handle":
|
|
328
|
-
return "Solved.ac \uC0AC\uC6A9\uC790 \uD578\uB4E4";
|
|
329
|
-
case "problem-dir":
|
|
330
|
-
return '\uBB38\uC81C \uB514\uB809\uD1A0\uB9AC \uACBD\uB85C (\uAE30\uBCF8\uAC12: "problems", \uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8: ".")';
|
|
331
|
-
default:
|
|
332
|
-
return "";
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
const getSuggestions = () => {
|
|
336
|
-
switch (configKey) {
|
|
337
|
-
case "default-language":
|
|
338
|
-
return getSupportedLanguages();
|
|
339
|
-
case "editor":
|
|
340
|
-
return ["code", "cursor", "vim", "nano"];
|
|
341
|
-
case "auto-open-editor":
|
|
342
|
-
return ["true", "false"];
|
|
343
|
-
case "problem-dir":
|
|
344
|
-
return ["problems", ".", ""];
|
|
345
|
-
default:
|
|
346
|
-
return [];
|
|
347
|
-
}
|
|
401
|
+
) })
|
|
402
|
+
] });
|
|
348
403
|
};
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
404
|
+
// 설정 값 입력 컴포넌트: 클래스 내부에 정의
|
|
405
|
+
ConfigValueInput = ({
|
|
406
|
+
configKey,
|
|
407
|
+
onSubmit
|
|
408
|
+
}) => {
|
|
409
|
+
const getPlaceholder = () => {
|
|
410
|
+
switch (configKey) {
|
|
411
|
+
case "default-language":
|
|
412
|
+
return `\uC5B8\uC5B4 \uC785\uB825 (${getSupportedLanguagesString()})`;
|
|
413
|
+
case "editor":
|
|
414
|
+
return "\uC5D0\uB514\uD130 \uBA85\uB839\uC5B4 \uC785\uB825";
|
|
415
|
+
case "auto-open-editor":
|
|
416
|
+
return "true \uB610\uB294 false \uC785\uB825";
|
|
417
|
+
case "solved-ac-handle":
|
|
418
|
+
return "Solved.ac \uD578\uB4E4 \uC785\uB825";
|
|
419
|
+
case "problem-dir":
|
|
420
|
+
return "\uBB38\uC81C \uB514\uB809\uD1A0\uB9AC \uACBD\uB85C \uC785\uB825";
|
|
421
|
+
default:
|
|
422
|
+
return "\uAC12 \uC785\uB825";
|
|
360
423
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
424
|
+
};
|
|
425
|
+
const getDescription = () => {
|
|
426
|
+
switch (configKey) {
|
|
427
|
+
case "default-language":
|
|
428
|
+
return `\uC9C0\uC6D0 \uC5B8\uC5B4: ${getSupportedLanguagesString()}`;
|
|
429
|
+
case "editor":
|
|
430
|
+
return "\uC608: code, cursor, vim, nano";
|
|
431
|
+
case "auto-open-editor":
|
|
432
|
+
return "fetch \uD6C4 \uC790\uB3D9\uC73C\uB85C \uC5D0\uB514\uD130\uB97C \uC5F4\uC9C0 \uC5EC\uBD80";
|
|
433
|
+
case "solved-ac-handle":
|
|
434
|
+
return "Solved.ac \uC0AC\uC6A9\uC790 \uD578\uB4E4";
|
|
435
|
+
case "problem-dir":
|
|
436
|
+
return '\uBB38\uC81C \uB514\uB809\uD1A0\uB9AC \uACBD\uB85C (\uAE30\uBCF8\uAC12: "problems", \uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8: ".")';
|
|
437
|
+
default:
|
|
438
|
+
return "";
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
const getSuggestions = () => {
|
|
442
|
+
switch (configKey) {
|
|
443
|
+
case "default-language":
|
|
444
|
+
return getSupportedLanguages();
|
|
445
|
+
case "editor":
|
|
446
|
+
return ["code", "cursor", "vim", "nano"];
|
|
447
|
+
case "auto-open-editor":
|
|
448
|
+
return ["true", "false"];
|
|
449
|
+
case "problem-dir":
|
|
450
|
+
return ["problems", ".", ""];
|
|
451
|
+
default:
|
|
452
|
+
return [];
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
456
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Alert, { variant: "info", children: "\uAC12\uC744 \uC785\uB825\uD558\uC138\uC694" }) }),
|
|
457
|
+
getDescription() && /* @__PURE__ */ jsx(Box, { marginTop: 1, marginBottom: 0, children: /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: getDescription() }) }),
|
|
458
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 0, children: /* @__PURE__ */ jsx(
|
|
459
|
+
TextInput,
|
|
369
460
|
{
|
|
370
|
-
|
|
461
|
+
placeholder: getPlaceholder(),
|
|
462
|
+
suggestions: getSuggestions(),
|
|
371
463
|
onSubmit: (value) => {
|
|
372
|
-
|
|
373
|
-
resolve(value);
|
|
464
|
+
onSubmit(value);
|
|
374
465
|
}
|
|
375
466
|
}
|
|
376
|
-
)
|
|
377
|
-
);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
async function configExecute(args, flags) {
|
|
381
|
-
if (flags.help) {
|
|
382
|
-
console.log(getConfigHelp().trim());
|
|
383
|
-
process.exit(0);
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
const command = args[0];
|
|
387
|
-
if (command === "clear") {
|
|
388
|
-
await configCommand(void 0, void 0, false, false, true);
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
if (command === "list" || flags.list) {
|
|
392
|
-
await configCommand(void 0, void 0, false, true);
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
if (command === "get") {
|
|
396
|
-
const key = args[1];
|
|
397
|
-
if (key) {
|
|
398
|
-
await configCommand(key, void 0, true, false);
|
|
399
|
-
} else {
|
|
400
|
-
const selectedKey = await selectConfigKey();
|
|
401
|
-
if (!selectedKey) {
|
|
402
|
-
process.exit(0);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
await configCommand(selectedKey, void 0, true, false);
|
|
406
|
-
}
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
if (command === "set") {
|
|
410
|
-
const key = args[1];
|
|
411
|
-
if (key) {
|
|
412
|
-
const inputValue = await inputConfigValue(key);
|
|
413
|
-
if (!inputValue) {
|
|
414
|
-
process.exit(0);
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
await configCommand(key, inputValue, false, false);
|
|
418
|
-
} else {
|
|
419
|
-
const selectedKey = await selectConfigKey();
|
|
420
|
-
if (!selectedKey) {
|
|
421
|
-
process.exit(0);
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
const inputValue = await inputConfigValue(selectedKey);
|
|
425
|
-
if (!inputValue) {
|
|
426
|
-
process.exit(0);
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
await configCommand(selectedKey, inputValue, false, false);
|
|
430
|
-
}
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
if (!command) {
|
|
434
|
-
console.error("\uC624\uB958: \uBA85\uB839\uC5B4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.");
|
|
435
|
-
console.error("\uC0AC\uC6A9\uBC95: ps config <\uBA85\uB839\uC5B4>");
|
|
436
|
-
console.error("\uBA85\uB839\uC5B4: get, set, list, clear");
|
|
437
|
-
console.error("\uB3C4\uC6C0\uB9D0: ps config --help");
|
|
438
|
-
process.exit(1);
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
console.error(`\uC624\uB958: \uC54C \uC218 \uC5C6\uB294 \uBA85\uB839\uC5B4: ${command}`);
|
|
442
|
-
console.error("\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uBA85\uB839\uC5B4: get, set, list, clear");
|
|
443
|
-
console.error("\uB3C4\uC6C0\uB9D0: ps config --help");
|
|
444
|
-
process.exit(1);
|
|
445
|
-
}
|
|
446
|
-
var configCommandDef = {
|
|
447
|
-
name: "config",
|
|
448
|
-
help: configHelp,
|
|
449
|
-
execute: configExecute
|
|
467
|
+
) })
|
|
468
|
+
] });
|
|
469
|
+
};
|
|
450
470
|
};
|
|
451
|
-
|
|
471
|
+
ConfigCommand = __decorateClass([
|
|
472
|
+
CommandDef({
|
|
473
|
+
name: "config",
|
|
474
|
+
description: `\uD504\uB85C\uC81D\uD2B8 \uC124\uC815 \uD30C\uC77C(.ps-cli.json)\uC744 \uAD00\uB9AC\uD569\uB2C8\uB2E4.
|
|
475
|
+
\uC124\uC815\uC740 \uD604\uC7AC \uD504\uB85C\uC81D\uD2B8\uC758 .ps-cli.json \uD30C\uC77C\uC5D0 \uC800\uC7A5\uB429\uB2C8\uB2E4.`,
|
|
476
|
+
autoDetectProblemId: false,
|
|
477
|
+
examples: [
|
|
478
|
+
"config get # \uB300\uD654\uD615\uC73C\uB85C \uD0A4 \uC120\uD0DD \uD6C4 \uAC12 \uC870\uD68C",
|
|
479
|
+
"config get default-language # default-language \uAC12 \uC870\uD68C",
|
|
480
|
+
"config set # \uB300\uD654\uD615\uC73C\uB85C \uD0A4 \uC120\uD0DD \uD6C4 \uAC12 \uC124\uC815",
|
|
481
|
+
"config set editor cursor # editor\uB97C cursor\uB85C \uC124\uC815",
|
|
482
|
+
"config list # \uBAA8\uB4E0 \uC124\uC815 \uC870\uD68C",
|
|
483
|
+
"config clear # .ps-cli.json \uD30C\uC77C \uC0AD\uC81C"
|
|
484
|
+
]
|
|
485
|
+
})
|
|
486
|
+
], ConfigCommand);
|
|
487
|
+
var config_default = CommandBuilder.fromClass(ConfigCommand);
|
|
452
488
|
export {
|
|
453
|
-
|
|
489
|
+
ConfigCommand,
|
|
454
490
|
configHelp,
|
|
455
491
|
config_default as default,
|
|
456
492
|
getConfigHelp
|