@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/fetch.js
CHANGED
|
@@ -5,26 +5,191 @@ import {
|
|
|
5
5
|
getTierImageUrl,
|
|
6
6
|
getTierName,
|
|
7
7
|
source_default
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import {
|
|
10
|
-
getLanguageConfig,
|
|
11
|
-
getSupportedLanguages,
|
|
12
|
-
getSupportedLanguagesString
|
|
13
|
-
} from "../chunk-TQXMB7XV.js";
|
|
8
|
+
} from "../chunk-NB4OIWND.js";
|
|
14
9
|
import {
|
|
10
|
+
Command,
|
|
11
|
+
CommandBuilder,
|
|
12
|
+
CommandDef,
|
|
13
|
+
getAutoOpenEditor,
|
|
14
|
+
getEditor,
|
|
15
15
|
getProblemDirPath,
|
|
16
16
|
getProblemId
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-7SVCS23X.js";
|
|
18
18
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
__decorateClass,
|
|
20
|
+
getLanguageConfig,
|
|
21
|
+
getSupportedLanguages,
|
|
22
|
+
getSupportedLanguagesString
|
|
23
|
+
} from "../chunk-7MQMPJ3X.js";
|
|
23
24
|
|
|
24
25
|
// src/commands/fetch.tsx
|
|
25
|
-
import { useState, useEffect } from "react";
|
|
26
|
-
import { render, Box as Box2 } from "ink";
|
|
27
26
|
import { StatusMessage, Alert } from "@inkjs/ui";
|
|
27
|
+
import { Spinner } from "@inkjs/ui";
|
|
28
|
+
import { Box as Box2 } from "ink";
|
|
29
|
+
|
|
30
|
+
// src/components/problem-dashboard.tsx
|
|
31
|
+
import { Box, Text } from "ink";
|
|
32
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
+
function ProblemDashboard({ problem }) {
|
|
34
|
+
const tierName = getTierName(problem.level);
|
|
35
|
+
const tierColor = getTierColor(problem.level);
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
Box,
|
|
38
|
+
{
|
|
39
|
+
flexDirection: "column",
|
|
40
|
+
borderStyle: "round",
|
|
41
|
+
borderColor: tierColor,
|
|
42
|
+
paddingX: 1,
|
|
43
|
+
alignSelf: "flex-start",
|
|
44
|
+
children: /* @__PURE__ */ jsxs(Text, { bold: true, children: [
|
|
45
|
+
source_default.hex(tierColor)(tierName),
|
|
46
|
+
" ",
|
|
47
|
+
/* @__PURE__ */ jsxs(Text, { color: "white", children: [
|
|
48
|
+
"#",
|
|
49
|
+
problem.id,
|
|
50
|
+
": ",
|
|
51
|
+
problem.title
|
|
52
|
+
] })
|
|
53
|
+
] })
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/hooks/use-fetch-problem.ts
|
|
59
|
+
import { execaCommand } from "execa";
|
|
60
|
+
import { useEffect, useState } from "react";
|
|
61
|
+
|
|
62
|
+
// src/services/file-generator.ts
|
|
63
|
+
import { mkdir, writeFile, readFile } from "fs/promises";
|
|
64
|
+
import { join, dirname } from "path";
|
|
65
|
+
import { fileURLToPath } from "url";
|
|
66
|
+
function parseTimeLimitToMs(timeLimit) {
|
|
67
|
+
if (!timeLimit) return void 0;
|
|
68
|
+
const match = timeLimit.match(/([\d.]+)/);
|
|
69
|
+
if (!match) return void 0;
|
|
70
|
+
const seconds = parseFloat(match[1]);
|
|
71
|
+
if (Number.isNaN(seconds)) return void 0;
|
|
72
|
+
return Math.round(seconds * 1e3);
|
|
73
|
+
}
|
|
74
|
+
function getProjectRoot() {
|
|
75
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
76
|
+
const __dirname = dirname(__filename);
|
|
77
|
+
if (__dirname.includes("dist")) {
|
|
78
|
+
return join(__dirname, "../..");
|
|
79
|
+
}
|
|
80
|
+
return join(__dirname, "../..");
|
|
81
|
+
}
|
|
82
|
+
async function generateProblemFiles(problem, language = "python") {
|
|
83
|
+
const problemDir = getProblemDirPath(problem.id);
|
|
84
|
+
await mkdir(problemDir, { recursive: true });
|
|
85
|
+
const langConfig = getLanguageConfig(language);
|
|
86
|
+
const projectRoot = getProjectRoot();
|
|
87
|
+
const templatePath = join(projectRoot, "templates", langConfig.templateFile);
|
|
88
|
+
const solutionPath = join(problemDir, `solution.${langConfig.extension}`);
|
|
89
|
+
try {
|
|
90
|
+
const templateContent = await readFile(templatePath, "utf-8");
|
|
91
|
+
await writeFile(solutionPath, templateContent, "utf-8");
|
|
92
|
+
} catch {
|
|
93
|
+
await writeFile(
|
|
94
|
+
solutionPath,
|
|
95
|
+
`// Problem ${problem.id}: ${problem.title}
|
|
96
|
+
`,
|
|
97
|
+
"utf-8"
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
for (let i = 0; i < problem.testCases.length; i++) {
|
|
101
|
+
const testCase = problem.testCases[i];
|
|
102
|
+
const inputPath = join(problemDir, `input${i + 1}.txt`);
|
|
103
|
+
const outputPath = join(problemDir, `output${i + 1}.txt`);
|
|
104
|
+
await writeFile(inputPath, testCase.input, "utf-8");
|
|
105
|
+
await writeFile(outputPath, testCase.output, "utf-8");
|
|
106
|
+
}
|
|
107
|
+
const tierName = getTierName(problem.level);
|
|
108
|
+
const tierImageUrl = getTierImageUrl(problem.level);
|
|
109
|
+
const tags = problem.tags.length > 0 ? problem.tags.join(", ") : "\uC5C6\uC74C";
|
|
110
|
+
const headers = [];
|
|
111
|
+
const values = [];
|
|
112
|
+
headers.push("\uB09C\uC774\uB3C4");
|
|
113
|
+
values.push(`<img src="${tierImageUrl}" alt="${tierName}" width="20" />`);
|
|
114
|
+
if (problem.timeLimit) {
|
|
115
|
+
headers.push("\uC2DC\uAC04 \uC81C\uD55C");
|
|
116
|
+
values.push(problem.timeLimit);
|
|
117
|
+
}
|
|
118
|
+
if (problem.memoryLimit) {
|
|
119
|
+
headers.push("\uBA54\uBAA8\uB9AC \uC81C\uD55C");
|
|
120
|
+
values.push(problem.memoryLimit);
|
|
121
|
+
}
|
|
122
|
+
if (problem.submissions) {
|
|
123
|
+
headers.push("\uC81C\uCD9C");
|
|
124
|
+
values.push(problem.submissions);
|
|
125
|
+
}
|
|
126
|
+
if (problem.accepted) {
|
|
127
|
+
headers.push("\uC815\uB2F5");
|
|
128
|
+
values.push(problem.accepted);
|
|
129
|
+
}
|
|
130
|
+
if (problem.acceptedUsers) {
|
|
131
|
+
headers.push("\uB9DE\uD78C \uC0AC\uB78C");
|
|
132
|
+
values.push(problem.acceptedUsers);
|
|
133
|
+
}
|
|
134
|
+
if (problem.acceptedRate) {
|
|
135
|
+
headers.push("\uC815\uB2F5 \uBE44\uC728");
|
|
136
|
+
values.push(problem.acceptedRate);
|
|
137
|
+
}
|
|
138
|
+
let infoTable = "";
|
|
139
|
+
if (headers.length > 0) {
|
|
140
|
+
const headerRow = `| ${headers.join(" | ")} |`;
|
|
141
|
+
const separatorRow = `|${headers.map(() => "---").join("|")}|`;
|
|
142
|
+
const valueRow = `| ${values.join(" | ")} |`;
|
|
143
|
+
infoTable = `
|
|
144
|
+
${headerRow}
|
|
145
|
+
${separatorRow}
|
|
146
|
+
${valueRow}
|
|
147
|
+
`;
|
|
148
|
+
}
|
|
149
|
+
const readmeContent = `# [${problem.id}: ${problem.title}](https://www.acmicpc.net/problem/${problem.id})
|
|
150
|
+
|
|
151
|
+
${infoTable}## \uBB38\uC81C \uC124\uBA85
|
|
152
|
+
${problem.description || "\uC124\uBA85 \uC5C6\uC74C"}
|
|
153
|
+
|
|
154
|
+
## \uC785\uB825
|
|
155
|
+
${problem.inputFormat || "\uC785\uB825 \uD615\uC2DD \uC5C6\uC74C"}
|
|
156
|
+
|
|
157
|
+
## \uCD9C\uB825
|
|
158
|
+
${problem.outputFormat || "\uCD9C\uB825 \uD615\uC2DD \uC5C6\uC74C"}
|
|
159
|
+
|
|
160
|
+
## \uC608\uC81C
|
|
161
|
+
${problem.testCases.map(
|
|
162
|
+
(tc, i) => `### \uC608\uC81C ${i + 1}
|
|
163
|
+
|
|
164
|
+
**\uC785\uB825:**
|
|
165
|
+
\`\`\`
|
|
166
|
+
${tc.input.trimEnd()}
|
|
167
|
+
\`\`\`
|
|
168
|
+
|
|
169
|
+
**\uCD9C\uB825:**
|
|
170
|
+
\`\`\`
|
|
171
|
+
${tc.output.trimEnd()}
|
|
172
|
+
\`\`\`
|
|
173
|
+
`
|
|
174
|
+
).join("\n")}
|
|
175
|
+
|
|
176
|
+
## \uD0DC\uADF8
|
|
177
|
+
${tags}
|
|
178
|
+
`;
|
|
179
|
+
const readmePath = join(problemDir, "README.md");
|
|
180
|
+
await writeFile(readmePath, readmeContent, "utf-8");
|
|
181
|
+
const meta = {
|
|
182
|
+
id: problem.id,
|
|
183
|
+
title: problem.title,
|
|
184
|
+
level: problem.level,
|
|
185
|
+
timeLimit: problem.timeLimit,
|
|
186
|
+
timeLimitMs: parseTimeLimitToMs(problem.timeLimit),
|
|
187
|
+
memoryLimit: problem.memoryLimit
|
|
188
|
+
};
|
|
189
|
+
const metaPath = join(problemDir, "meta.json");
|
|
190
|
+
await writeFile(metaPath, JSON.stringify(meta, null, 2), "utf-8");
|
|
191
|
+
return problemDir;
|
|
192
|
+
}
|
|
28
193
|
|
|
29
194
|
// src/services/scraper.ts
|
|
30
195
|
import * as cheerio from "cheerio";
|
|
@@ -63,25 +228,27 @@ function htmlToMarkdown($, element) {
|
|
|
63
228
|
case "br":
|
|
64
229
|
result += "\n";
|
|
65
230
|
break;
|
|
66
|
-
case "p":
|
|
231
|
+
case "p": {
|
|
67
232
|
const pContent = htmlToMarkdown($, $node);
|
|
68
233
|
if (pContent) {
|
|
69
234
|
result += pContent + "\n\n";
|
|
70
235
|
}
|
|
71
236
|
break;
|
|
72
|
-
|
|
237
|
+
}
|
|
238
|
+
case "div": {
|
|
73
239
|
const divContent = htmlToMarkdown($, $node);
|
|
74
240
|
if (divContent) {
|
|
75
241
|
result += divContent + "\n";
|
|
76
242
|
}
|
|
77
243
|
break;
|
|
244
|
+
}
|
|
78
245
|
case "span":
|
|
79
246
|
result += htmlToMarkdown($, $node);
|
|
80
247
|
break;
|
|
81
248
|
case "code":
|
|
82
249
|
result += `\`${htmlToMarkdown($, $node)}\``;
|
|
83
250
|
break;
|
|
84
|
-
case "pre":
|
|
251
|
+
case "pre": {
|
|
85
252
|
const preContent = htmlToMarkdown($, $node);
|
|
86
253
|
if (preContent) {
|
|
87
254
|
result += `
|
|
@@ -91,6 +258,7 @@ ${preContent}
|
|
|
91
258
|
`;
|
|
92
259
|
}
|
|
93
260
|
break;
|
|
261
|
+
}
|
|
94
262
|
case "ul":
|
|
95
263
|
case "ol":
|
|
96
264
|
$node.find("li").each((i, li) => {
|
|
@@ -104,7 +272,7 @@ ${preContent}
|
|
|
104
272
|
case "li":
|
|
105
273
|
result += htmlToMarkdown($, $node);
|
|
106
274
|
break;
|
|
107
|
-
case "img":
|
|
275
|
+
case "img": {
|
|
108
276
|
const imgSrc = $node.attr("src") || "";
|
|
109
277
|
const imgAlt = $node.attr("alt") || "";
|
|
110
278
|
if (imgSrc) {
|
|
@@ -117,6 +285,7 @@ ${preContent}
|
|
|
117
285
|
result += ``;
|
|
118
286
|
}
|
|
119
287
|
break;
|
|
288
|
+
}
|
|
120
289
|
default:
|
|
121
290
|
result += htmlToMarkdown($, $node);
|
|
122
291
|
}
|
|
@@ -268,173 +437,10 @@ async function scrapeProblem(problemId) {
|
|
|
268
437
|
};
|
|
269
438
|
}
|
|
270
439
|
|
|
271
|
-
// src/
|
|
272
|
-
|
|
273
|
-
import { join, dirname } from "path";
|
|
274
|
-
import { fileURLToPath } from "url";
|
|
275
|
-
function parseTimeLimitToMs(timeLimit) {
|
|
276
|
-
if (!timeLimit) return void 0;
|
|
277
|
-
const match = timeLimit.match(/([\d.]+)/);
|
|
278
|
-
if (!match) return void 0;
|
|
279
|
-
const seconds = parseFloat(match[1]);
|
|
280
|
-
if (Number.isNaN(seconds)) return void 0;
|
|
281
|
-
return Math.round(seconds * 1e3);
|
|
282
|
-
}
|
|
283
|
-
function getProjectRoot() {
|
|
284
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
285
|
-
const __dirname = dirname(__filename);
|
|
286
|
-
if (__dirname.includes("dist")) {
|
|
287
|
-
return join(__dirname, "../..");
|
|
288
|
-
}
|
|
289
|
-
return join(__dirname, "../..");
|
|
290
|
-
}
|
|
291
|
-
async function generateProblemFiles(problem, language = "python") {
|
|
292
|
-
const problemDir = getProblemDirPath(problem.id);
|
|
293
|
-
await mkdir(problemDir, { recursive: true });
|
|
294
|
-
const langConfig = getLanguageConfig(language);
|
|
295
|
-
const projectRoot = getProjectRoot();
|
|
296
|
-
const templatePath = join(projectRoot, "templates", langConfig.templateFile);
|
|
297
|
-
const solutionPath = join(problemDir, `solution.${langConfig.extension}`);
|
|
298
|
-
try {
|
|
299
|
-
const templateContent = await readFile(templatePath, "utf-8");
|
|
300
|
-
await writeFile(solutionPath, templateContent, "utf-8");
|
|
301
|
-
} catch (error) {
|
|
302
|
-
await writeFile(
|
|
303
|
-
solutionPath,
|
|
304
|
-
`// Problem ${problem.id}: ${problem.title}
|
|
305
|
-
`,
|
|
306
|
-
"utf-8"
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
for (let i = 0; i < problem.testCases.length; i++) {
|
|
310
|
-
const testCase = problem.testCases[i];
|
|
311
|
-
const inputPath = join(problemDir, `input${i + 1}.txt`);
|
|
312
|
-
const outputPath = join(problemDir, `output${i + 1}.txt`);
|
|
313
|
-
await writeFile(inputPath, testCase.input, "utf-8");
|
|
314
|
-
await writeFile(outputPath, testCase.output, "utf-8");
|
|
315
|
-
}
|
|
316
|
-
const tierName = getTierName(problem.level);
|
|
317
|
-
const tierImageUrl = getTierImageUrl(problem.level);
|
|
318
|
-
const tags = problem.tags.length > 0 ? problem.tags.join(", ") : "\uC5C6\uC74C";
|
|
319
|
-
const headers = [];
|
|
320
|
-
const values = [];
|
|
321
|
-
headers.push("\uB09C\uC774\uB3C4");
|
|
322
|
-
values.push(`<img src="${tierImageUrl}" alt="${tierName}" width="20" />`);
|
|
323
|
-
if (problem.timeLimit) {
|
|
324
|
-
headers.push("\uC2DC\uAC04 \uC81C\uD55C");
|
|
325
|
-
values.push(problem.timeLimit);
|
|
326
|
-
}
|
|
327
|
-
if (problem.memoryLimit) {
|
|
328
|
-
headers.push("\uBA54\uBAA8\uB9AC \uC81C\uD55C");
|
|
329
|
-
values.push(problem.memoryLimit);
|
|
330
|
-
}
|
|
331
|
-
if (problem.submissions) {
|
|
332
|
-
headers.push("\uC81C\uCD9C");
|
|
333
|
-
values.push(problem.submissions);
|
|
334
|
-
}
|
|
335
|
-
if (problem.accepted) {
|
|
336
|
-
headers.push("\uC815\uB2F5");
|
|
337
|
-
values.push(problem.accepted);
|
|
338
|
-
}
|
|
339
|
-
if (problem.acceptedUsers) {
|
|
340
|
-
headers.push("\uB9DE\uD78C \uC0AC\uB78C");
|
|
341
|
-
values.push(problem.acceptedUsers);
|
|
342
|
-
}
|
|
343
|
-
if (problem.acceptedRate) {
|
|
344
|
-
headers.push("\uC815\uB2F5 \uBE44\uC728");
|
|
345
|
-
values.push(problem.acceptedRate);
|
|
346
|
-
}
|
|
347
|
-
let infoTable = "";
|
|
348
|
-
if (headers.length > 0) {
|
|
349
|
-
const headerRow = `| ${headers.join(" | ")} |`;
|
|
350
|
-
const separatorRow = `|${headers.map(() => "---").join("|")}|`;
|
|
351
|
-
const valueRow = `| ${values.join(" | ")} |`;
|
|
352
|
-
infoTable = `
|
|
353
|
-
${headerRow}
|
|
354
|
-
${separatorRow}
|
|
355
|
-
${valueRow}
|
|
356
|
-
`;
|
|
357
|
-
}
|
|
358
|
-
const readmeContent = `# [${problem.id}: ${problem.title}](https://www.acmicpc.net/problem/${problem.id})
|
|
359
|
-
|
|
360
|
-
${infoTable}## \uBB38\uC81C \uC124\uBA85
|
|
361
|
-
${problem.description || "\uC124\uBA85 \uC5C6\uC74C"}
|
|
362
|
-
|
|
363
|
-
## \uC785\uB825
|
|
364
|
-
${problem.inputFormat || "\uC785\uB825 \uD615\uC2DD \uC5C6\uC74C"}
|
|
365
|
-
|
|
366
|
-
## \uCD9C\uB825
|
|
367
|
-
${problem.outputFormat || "\uCD9C\uB825 \uD615\uC2DD \uC5C6\uC74C"}
|
|
368
|
-
|
|
369
|
-
## \uC608\uC81C
|
|
370
|
-
${problem.testCases.map(
|
|
371
|
-
(tc, i) => `### \uC608\uC81C ${i + 1}
|
|
372
|
-
|
|
373
|
-
**\uC785\uB825:**
|
|
374
|
-
\`\`\`
|
|
375
|
-
${tc.input.trimEnd()}
|
|
376
|
-
\`\`\`
|
|
377
|
-
|
|
378
|
-
**\uCD9C\uB825:**
|
|
379
|
-
\`\`\`
|
|
380
|
-
${tc.output.trimEnd()}
|
|
381
|
-
\`\`\`
|
|
382
|
-
`
|
|
383
|
-
).join("\n")}
|
|
384
|
-
|
|
385
|
-
## \uD0DC\uADF8
|
|
386
|
-
${tags}
|
|
387
|
-
`;
|
|
388
|
-
const readmePath = join(problemDir, "README.md");
|
|
389
|
-
await writeFile(readmePath, readmeContent, "utf-8");
|
|
390
|
-
const meta = {
|
|
391
|
-
id: problem.id,
|
|
392
|
-
title: problem.title,
|
|
393
|
-
level: problem.level,
|
|
394
|
-
timeLimit: problem.timeLimit,
|
|
395
|
-
timeLimitMs: parseTimeLimitToMs(problem.timeLimit),
|
|
396
|
-
memoryLimit: problem.memoryLimit
|
|
397
|
-
};
|
|
398
|
-
const metaPath = join(problemDir, "meta.json");
|
|
399
|
-
await writeFile(metaPath, JSON.stringify(meta, null, 2), "utf-8");
|
|
400
|
-
return problemDir;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// src/components/problem-dashboard.tsx
|
|
404
|
-
import { Box, Text } from "ink";
|
|
405
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
406
|
-
function ProblemDashboard({ problem }) {
|
|
407
|
-
const tierName = getTierName(problem.level);
|
|
408
|
-
const tierColor = getTierColor(problem.level);
|
|
409
|
-
return /* @__PURE__ */ jsx(
|
|
410
|
-
Box,
|
|
411
|
-
{
|
|
412
|
-
flexDirection: "column",
|
|
413
|
-
borderStyle: "round",
|
|
414
|
-
borderColor: tierColor,
|
|
415
|
-
paddingX: 1,
|
|
416
|
-
alignSelf: "flex-start",
|
|
417
|
-
children: /* @__PURE__ */ jsxs(Text, { bold: true, children: [
|
|
418
|
-
source_default.hex(tierColor)(tierName),
|
|
419
|
-
" ",
|
|
420
|
-
/* @__PURE__ */ jsxs(Text, { color: "white", children: [
|
|
421
|
-
"#",
|
|
422
|
-
problem.id,
|
|
423
|
-
": ",
|
|
424
|
-
problem.title
|
|
425
|
-
] })
|
|
426
|
-
] })
|
|
427
|
-
}
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// src/commands/fetch.tsx
|
|
432
|
-
import { Spinner } from "@inkjs/ui";
|
|
433
|
-
import { execaCommand } from "execa";
|
|
434
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
435
|
-
function FetchCommand({
|
|
440
|
+
// src/hooks/use-fetch-problem.ts
|
|
441
|
+
function useFetchProblem({
|
|
436
442
|
problemId,
|
|
437
|
-
language
|
|
443
|
+
language,
|
|
438
444
|
onComplete
|
|
439
445
|
}) {
|
|
440
446
|
const [status, setStatus] = useState(
|
|
@@ -511,8 +517,28 @@ ${editor}\uB85C \uC5F4\uC5C8\uC2B5\uB2C8\uB2E4.`
|
|
|
511
517
|
}, 2e3);
|
|
512
518
|
}
|
|
513
519
|
}
|
|
514
|
-
fetchProblem();
|
|
520
|
+
void fetchProblem();
|
|
515
521
|
}, [problemId, language, onComplete]);
|
|
522
|
+
return {
|
|
523
|
+
status,
|
|
524
|
+
problem,
|
|
525
|
+
error,
|
|
526
|
+
message
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// src/commands/fetch.tsx
|
|
531
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
532
|
+
function FetchView({
|
|
533
|
+
problemId,
|
|
534
|
+
language = "python",
|
|
535
|
+
onComplete
|
|
536
|
+
}) {
|
|
537
|
+
const { status, problem, error, message } = useFetchProblem({
|
|
538
|
+
problemId,
|
|
539
|
+
language,
|
|
540
|
+
onComplete
|
|
541
|
+
});
|
|
516
542
|
if (status === "loading") {
|
|
517
543
|
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", children: [
|
|
518
544
|
/* @__PURE__ */ jsx2(Spinner, { label: message }),
|
|
@@ -530,77 +556,59 @@ ${editor}\uB85C \uC5F4\uC5C8\uC2B5\uB2C8\uB2E4.`
|
|
|
530
556
|
/* @__PURE__ */ jsx2(StatusMessage, { variant: "success", children: message })
|
|
531
557
|
] });
|
|
532
558
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
- README.md\uC5D0 \uBB38\uC81C \uC815\uBCF4, \uD1B5\uACC4, \uD0DC\uADF8 \uB4F1 \uD3EC\uD568
|
|
560
|
-
|
|
561
|
-
\uC635\uC158:
|
|
562
|
-
--language, -l \uC5B8\uC5B4 \uC120\uD0DD (${getSupportedLanguagesString()})
|
|
563
|
-
\uAE30\uBCF8\uAC12: python
|
|
564
|
-
|
|
565
|
-
\uC608\uC81C:
|
|
566
|
-
$ ps fetch 1000
|
|
567
|
-
$ ps fetch 1000 --language python
|
|
568
|
-
$ ps fetch 1000 -l cpp
|
|
569
|
-
`;
|
|
570
|
-
async function fetchExecute(args, flags) {
|
|
571
|
-
if (flags.help) {
|
|
572
|
-
console.log(fetchHelp.trim());
|
|
573
|
-
process.exit(0);
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
const problemId = getProblemId(args);
|
|
577
|
-
if (problemId === null) {
|
|
578
|
-
console.error("\uC624\uB958: \uBB38\uC81C \uBC88\uD638\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.");
|
|
579
|
-
console.error(`\uC0AC\uC6A9\uBC95: ps fetch <\uBB38\uC81C\uBC88\uD638> [\uC635\uC158]`);
|
|
580
|
-
console.error(`\uB3C4\uC6C0\uB9D0: ps fetch --help`);
|
|
581
|
-
console.error(
|
|
582
|
-
`\uD78C\uD2B8: problems/{\uBB38\uC81C\uBC88\uD638} \uB514\uB809\uD1A0\uB9AC\uC5D0\uC11C \uC2E4\uD589\uD558\uBA74 \uC790\uB3D9\uC73C\uB85C \uBB38\uC81C \uBC88\uD638\uB97C \uCD94\uB860\uD569\uB2C8\uB2E4.`
|
|
583
|
-
);
|
|
584
|
-
process.exit(1);
|
|
585
|
-
}
|
|
586
|
-
const validLanguages = getSupportedLanguages();
|
|
587
|
-
const language = flags.language;
|
|
588
|
-
if (language && !validLanguages.includes(language)) {
|
|
589
|
-
console.error(
|
|
590
|
-
`\uC624\uB958: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC5B8\uC5B4\uC785\uB2C8\uB2E4. (${getSupportedLanguagesString()})`
|
|
591
|
-
);
|
|
592
|
-
process.exit(1);
|
|
559
|
+
var FetchCommand = class extends Command {
|
|
560
|
+
async execute(args, flags) {
|
|
561
|
+
const problemId = getProblemId(args);
|
|
562
|
+
if (problemId === null) {
|
|
563
|
+
console.error("\uC624\uB958: \uBB38\uC81C \uBC88\uD638\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.");
|
|
564
|
+
console.error(`\uC0AC\uC6A9\uBC95: ps fetch <\uBB38\uC81C\uBC88\uD638> [\uC635\uC158]`);
|
|
565
|
+
console.error(`\uB3C4\uC6C0\uB9D0: ps fetch --help`);
|
|
566
|
+
console.error(
|
|
567
|
+
`\uD78C\uD2B8: problems/{\uBB38\uC81C\uBC88\uD638} \uB514\uB809\uD1A0\uB9AC\uC5D0\uC11C \uC2E4\uD589\uD558\uBA74 \uC790\uB3D9\uC73C\uB85C \uBB38\uC81C \uBC88\uD638\uB97C \uCD94\uB860\uD569\uB2C8\uB2E4.`
|
|
568
|
+
);
|
|
569
|
+
process.exit(1);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const validLanguages = getSupportedLanguages();
|
|
573
|
+
const language = flags.language;
|
|
574
|
+
if (language && !validLanguages.includes(language)) {
|
|
575
|
+
console.error(
|
|
576
|
+
`\uC624\uB958: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC5B8\uC5B4\uC785\uB2C8\uB2E4. (${getSupportedLanguagesString()})`
|
|
577
|
+
);
|
|
578
|
+
process.exit(1);
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
await this.renderView(FetchView, {
|
|
582
|
+
problemId,
|
|
583
|
+
language: language || "python"
|
|
584
|
+
});
|
|
593
585
|
}
|
|
594
|
-
await fetchCommand(problemId, language || "python");
|
|
595
|
-
}
|
|
596
|
-
var fetchCommandDef = {
|
|
597
|
-
name: "fetch",
|
|
598
|
-
help: fetchHelp,
|
|
599
|
-
execute: fetchExecute
|
|
600
586
|
};
|
|
601
|
-
|
|
587
|
+
FetchCommand = __decorateClass([
|
|
588
|
+
CommandDef({
|
|
589
|
+
name: "fetch",
|
|
590
|
+
description: `\uBC31\uC900 \uBB38\uC81C\uB97C \uAC00\uC838\uC640\uC11C \uB85C\uCEEC\uC5D0 \uD30C\uC77C\uC744 \uC0DD\uC131\uD569\uB2C8\uB2E4.
|
|
591
|
+
- Solved.ac API\uC640 BOJ \uD06C\uB864\uB9C1\uC744 \uD1B5\uD574 \uBB38\uC81C \uC815\uBCF4 \uC218\uC9D1
|
|
592
|
+
- \uBB38\uC81C \uC124\uBA85, \uC785\uCD9C\uB825 \uD615\uC2DD, \uC608\uC81C \uC785\uCD9C\uB825 \uD30C\uC77C \uC790\uB3D9 \uC0DD\uC131
|
|
593
|
+
- \uC120\uD0DD\uD55C \uC5B8\uC5B4\uC758 \uC194\uB8E8\uC158 \uD15C\uD50C\uB9BF \uD30C\uC77C \uC0DD\uC131
|
|
594
|
+
- README.md\uC5D0 \uBB38\uC81C \uC815\uBCF4, \uD1B5\uACC4, \uD0DC\uADF8 \uB4F1 \uD3EC\uD568`,
|
|
595
|
+
flags: [
|
|
596
|
+
{
|
|
597
|
+
name: "language",
|
|
598
|
+
options: {
|
|
599
|
+
shortFlag: "l",
|
|
600
|
+
description: `\uC5B8\uC5B4 \uC120\uD0DD (${getSupportedLanguagesString()})
|
|
601
|
+
\uAE30\uBCF8\uAC12: python`
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
],
|
|
605
|
+
autoDetectProblemId: false,
|
|
606
|
+
requireProblemId: true,
|
|
607
|
+
examples: ["fetch 1000", "fetch 1000 --language python", "fetch 1000 -l cpp"]
|
|
608
|
+
})
|
|
609
|
+
], FetchCommand);
|
|
610
|
+
var fetch_default = CommandBuilder.fromClass(FetchCommand);
|
|
602
611
|
export {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
fetchHelp
|
|
612
|
+
FetchCommand,
|
|
613
|
+
fetch_default as default
|
|
606
614
|
};
|