@rhseung/ps-cli 1.3.3 → 1.5.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-A6STXEAE.js +54 -0
- package/dist/chunk-AG6KWWHS.js +342 -0
- package/dist/chunk-GCOFFYJ3.js +47 -0
- package/dist/{chunk-2E4VSP6O.js → chunk-HDNNR5OY.js} +200 -140
- 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 +128 -359
- package/dist/commands/init.js +138 -101
- package/dist/commands/open.js +56 -100
- package/dist/commands/run.js +99 -98
- package/dist/commands/search.js +246 -0
- package/dist/commands/stats.js +97 -77
- 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/run.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
runSolution
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-OJZLQ6FK.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
Command,
|
|
7
|
+
CommandBuilder,
|
|
8
|
+
CommandDef,
|
|
9
|
+
getProblemId,
|
|
10
|
+
resolveLanguage,
|
|
11
|
+
resolveProblemContext
|
|
12
|
+
} from "../chunk-7SVCS23X.js";
|
|
10
13
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "../chunk-6ENX5K3C.js";
|
|
15
|
-
import "../chunk-PNIGP6LX.js";
|
|
16
|
-
import "../chunk-FYS2JH42.js";
|
|
14
|
+
__decorateClass,
|
|
15
|
+
getSupportedLanguagesString
|
|
16
|
+
} from "../chunk-7MQMPJ3X.js";
|
|
17
17
|
|
|
18
18
|
// src/commands/run.tsx
|
|
19
|
-
import { useEffect, useState } from "react";
|
|
20
|
-
import { render, Box, Text } from "ink";
|
|
21
|
-
import { StatusMessage, Alert } from "@inkjs/ui";
|
|
22
19
|
import { readdir } from "fs/promises";
|
|
23
20
|
import { join } from "path";
|
|
21
|
+
import { StatusMessage, Alert } from "@inkjs/ui";
|
|
24
22
|
import { Spinner } from "@inkjs/ui";
|
|
25
|
-
import {
|
|
26
|
-
|
|
23
|
+
import { Box, Text } from "ink";
|
|
24
|
+
|
|
25
|
+
// src/hooks/use-run-solution.ts
|
|
26
|
+
import { useEffect, useState } from "react";
|
|
27
|
+
function useRunSolution({
|
|
27
28
|
problemDir,
|
|
28
29
|
language,
|
|
29
30
|
inputFile,
|
|
@@ -55,6 +56,27 @@ function RunCommand({
|
|
|
55
56
|
}, 2e3);
|
|
56
57
|
});
|
|
57
58
|
}, [problemDir, language, inputFile, onComplete]);
|
|
59
|
+
return {
|
|
60
|
+
status,
|
|
61
|
+
result,
|
|
62
|
+
error
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/commands/run.tsx
|
|
67
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
68
|
+
function RunView({
|
|
69
|
+
problemDir,
|
|
70
|
+
language,
|
|
71
|
+
inputFile,
|
|
72
|
+
onComplete
|
|
73
|
+
}) {
|
|
74
|
+
const { status, result, error } = useRunSolution({
|
|
75
|
+
problemDir,
|
|
76
|
+
language,
|
|
77
|
+
inputFile,
|
|
78
|
+
onComplete
|
|
79
|
+
});
|
|
58
80
|
if (status === "loading") {
|
|
59
81
|
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: /* @__PURE__ */ jsx(Spinner, { label: "\uCF54\uB4DC \uC2E4\uD589 \uC911..." }) });
|
|
60
82
|
}
|
|
@@ -99,91 +121,70 @@ function RunCommand({
|
|
|
99
121
|
}
|
|
100
122
|
return null;
|
|
101
123
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
return join(problemDir, inputFile);
|
|
109
|
-
}
|
|
110
|
-
async function runCommand(problemId, language, inputFile) {
|
|
111
|
-
const currentPathProblemId = detectProblemIdFromPath(process.cwd());
|
|
112
|
-
const problemDir = problemId && currentPathProblemId !== problemId ? getProblemDirPath(problemId) : process.cwd();
|
|
113
|
-
const inputPath = inputFile ? join(problemDir, inputFile) : await findInputFile(problemDir);
|
|
114
|
-
const files = await readdir(problemDir);
|
|
115
|
-
const solutionFile = files.find((f) => f.startsWith("solution."));
|
|
116
|
-
if (!solutionFile) {
|
|
117
|
-
throw new Error("solution.* \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
118
|
-
}
|
|
119
|
-
const detectedLanguage = language ?? detectLanguageFromFile(solutionFile);
|
|
120
|
-
if (!detectedLanguage) {
|
|
121
|
-
throw new Error(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC5B8\uC5B4\uC785\uB2C8\uB2E4: ${solutionFile}`);
|
|
122
|
-
}
|
|
123
|
-
return new Promise((resolve) => {
|
|
124
|
-
const { unmount } = render(
|
|
125
|
-
/* @__PURE__ */ jsx(
|
|
126
|
-
RunCommand,
|
|
127
|
-
{
|
|
128
|
-
problemDir,
|
|
129
|
-
language: detectedLanguage,
|
|
130
|
-
inputFile: inputPath,
|
|
131
|
-
onComplete: () => {
|
|
132
|
-
unmount();
|
|
133
|
-
resolve();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
)
|
|
124
|
+
var RunCommand = class extends Command {
|
|
125
|
+
async execute(args, flags) {
|
|
126
|
+
const problemId = getProblemId(args);
|
|
127
|
+
const context = await resolveProblemContext(
|
|
128
|
+
problemId !== null ? [problemId.toString()] : []
|
|
137
129
|
);
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
$ ps run [\uBB38\uC81C\uBC88\uD638] [\uC635\uC158]
|
|
143
|
-
|
|
144
|
-
\uC124\uBA85:
|
|
145
|
-
\uCF54\uB4DC\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4 (\uD14C\uC2A4\uD2B8 \uC5C6\uC774).
|
|
146
|
-
- \uD604\uC7AC \uB514\uB809\uD1A0\uB9AC \uB610\uB294 \uC9C0\uC815\uD55C \uBB38\uC81C \uBC88\uD638\uC758 \uCF54\uB4DC \uC2E4\uD589
|
|
147
|
-
- solution.* \uD30C\uC77C\uC744 \uC790\uB3D9\uC73C\uB85C \uCC3E\uC544 \uC5B8\uC5B4 \uAC10\uC9C0
|
|
148
|
-
- input.txt \uB610\uB294 input1.txt\uB97C \uD45C\uC900 \uC785\uB825\uC73C\uB85C \uC0AC\uC6A9
|
|
149
|
-
- \uD14C\uC2A4\uD2B8 \uCF00\uC774\uC2A4 \uAC80\uC99D \uC5C6\uC774 \uB2E8\uC21C \uC2E4\uD589
|
|
150
|
-
|
|
151
|
-
\uC635\uC158:
|
|
152
|
-
--language, -l \uC5B8\uC5B4 \uC120\uD0DD (\uC9C0\uC815 \uC2DC \uC790\uB3D9 \uAC10\uC9C0 \uBB34\uC2DC)
|
|
153
|
-
\uC9C0\uC6D0 \uC5B8\uC5B4: ${getSupportedLanguagesString()}
|
|
154
|
-
--input, -i \uC785\uB825 \uD30C\uC77C \uC9C0\uC815 (\uAE30\uBCF8\uAC12: input.txt \uB610\uB294 input1.txt)
|
|
155
|
-
|
|
156
|
-
\uC608\uC81C:
|
|
157
|
-
$ ps run # \uD604\uC7AC \uB514\uB809\uD1A0\uB9AC\uC5D0\uC11C \uC2E4\uD589
|
|
158
|
-
$ ps run 1000 # 1000\uBC88 \uBB38\uC81C \uC2E4\uD589
|
|
159
|
-
$ ps run --language python # Python\uC73C\uB85C \uC2E4\uD589
|
|
160
|
-
$ ps run --input input2.txt # \uD2B9\uC815 \uC785\uB825 \uD30C\uC77C \uC0AC\uC6A9
|
|
161
|
-
`;
|
|
162
|
-
async function runExecute(args, flags) {
|
|
163
|
-
if (flags.help) {
|
|
164
|
-
console.log(runHelp.trim());
|
|
165
|
-
process.exit(0);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const problemId = getProblemId(args);
|
|
169
|
-
const validLanguages = getSupportedLanguages();
|
|
170
|
-
const language = flags.language;
|
|
171
|
-
if (flags.language && language && !validLanguages.includes(language)) {
|
|
172
|
-
console.error(
|
|
173
|
-
`\uC624\uB958: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC5B8\uC5B4\uC785\uB2C8\uB2E4. (${getSupportedLanguagesString()})`
|
|
130
|
+
const inputPath = flags.input ? join(context.problemDir, flags.input) : await this.findInputFile(context.problemDir);
|
|
131
|
+
const detectedLanguage = await resolveLanguage(
|
|
132
|
+
context.problemDir,
|
|
133
|
+
flags.language
|
|
174
134
|
);
|
|
175
|
-
|
|
135
|
+
await this.renderView(RunView, {
|
|
136
|
+
problemDir: context.problemDir,
|
|
137
|
+
language: detectedLanguage,
|
|
138
|
+
inputFile: inputPath
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// 입력 파일 찾기: private 메서드
|
|
142
|
+
async findInputFile(problemDir) {
|
|
143
|
+
const files = await readdir(problemDir);
|
|
144
|
+
const inputFile = files.find((f) => f === "input1.txt") || files.find((f) => f === "input.txt");
|
|
145
|
+
if (!inputFile) {
|
|
146
|
+
throw new Error("input.txt \uB610\uB294 input1.txt \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
147
|
+
}
|
|
148
|
+
return join(problemDir, inputFile);
|
|
176
149
|
}
|
|
177
|
-
await runCommand(problemId, language, flags.input);
|
|
178
|
-
}
|
|
179
|
-
var runCommandDef = {
|
|
180
|
-
name: "run",
|
|
181
|
-
help: runHelp,
|
|
182
|
-
execute: runExecute
|
|
183
150
|
};
|
|
184
|
-
|
|
151
|
+
RunCommand = __decorateClass([
|
|
152
|
+
CommandDef({
|
|
153
|
+
name: "run",
|
|
154
|
+
description: `\uCF54\uB4DC\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4 (\uD14C\uC2A4\uD2B8 \uC5C6\uC774).
|
|
155
|
+
- \uD604\uC7AC \uB514\uB809\uD1A0\uB9AC \uB610\uB294 \uC9C0\uC815\uD55C \uBB38\uC81C \uBC88\uD638\uC758 \uCF54\uB4DC \uC2E4\uD589
|
|
156
|
+
- solution.* \uD30C\uC77C\uC744 \uC790\uB3D9\uC73C\uB85C \uCC3E\uC544 \uC5B8\uC5B4 \uAC10\uC9C0
|
|
157
|
+
- input.txt \uB610\uB294 input1.txt\uB97C \uD45C\uC900 \uC785\uB825\uC73C\uB85C \uC0AC\uC6A9
|
|
158
|
+
- \uD14C\uC2A4\uD2B8 \uCF00\uC774\uC2A4 \uAC80\uC99D \uC5C6\uC774 \uB2E8\uC21C \uC2E4\uD589`,
|
|
159
|
+
flags: [
|
|
160
|
+
{
|
|
161
|
+
name: "language",
|
|
162
|
+
options: {
|
|
163
|
+
shortFlag: "l",
|
|
164
|
+
description: `\uC5B8\uC5B4 \uC120\uD0DD (\uC9C0\uC815 \uC2DC \uC790\uB3D9 \uAC10\uC9C0 \uBB34\uC2DC)
|
|
165
|
+
\uC9C0\uC6D0 \uC5B8\uC5B4: ${getSupportedLanguagesString()}`
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "input",
|
|
170
|
+
options: {
|
|
171
|
+
shortFlag: "i",
|
|
172
|
+
description: "\uC785\uB825 \uD30C\uC77C \uC9C0\uC815 (\uAE30\uBCF8\uAC12: input.txt \uB610\uB294 input1.txt)"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
autoDetectProblemId: true,
|
|
177
|
+
autoDetectLanguage: true,
|
|
178
|
+
examples: [
|
|
179
|
+
"run # \uD604\uC7AC \uB514\uB809\uD1A0\uB9AC\uC5D0\uC11C \uC2E4\uD589",
|
|
180
|
+
"run 1000 # 1000\uBC88 \uBB38\uC81C \uC2E4\uD589",
|
|
181
|
+
"run --language python # Python\uC73C\uB85C \uC2E4\uD589",
|
|
182
|
+
"run --input input2.txt # \uD2B9\uC815 \uC785\uB825 \uD30C\uC77C \uC0AC\uC6A9"
|
|
183
|
+
]
|
|
184
|
+
})
|
|
185
|
+
], RunCommand);
|
|
186
|
+
var run_default = CommandBuilder.fromClass(RunCommand);
|
|
185
187
|
export {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
runHelp
|
|
188
|
+
RunCommand,
|
|
189
|
+
run_default as default
|
|
189
190
|
};
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
searchProblems
|
|
4
|
+
} from "../chunk-AG6KWWHS.js";
|
|
5
|
+
import {
|
|
6
|
+
useOpenBrowser
|
|
7
|
+
} from "../chunk-GCOFFYJ3.js";
|
|
8
|
+
import "../chunk-QGMWUOJ3.js";
|
|
9
|
+
import {
|
|
10
|
+
getTierColor,
|
|
11
|
+
getTierName,
|
|
12
|
+
source_default
|
|
13
|
+
} from "../chunk-HDNNR5OY.js";
|
|
14
|
+
import {
|
|
15
|
+
Command,
|
|
16
|
+
CommandBuilder,
|
|
17
|
+
CommandDef,
|
|
18
|
+
getProblemDirPath
|
|
19
|
+
} from "../chunk-7SVCS23X.js";
|
|
20
|
+
import {
|
|
21
|
+
__decorateClass
|
|
22
|
+
} from "../chunk-7MQMPJ3X.js";
|
|
23
|
+
|
|
24
|
+
// src/commands/search.tsx
|
|
25
|
+
import { existsSync } from "fs";
|
|
26
|
+
import { Alert, Select, Spinner } from "@inkjs/ui";
|
|
27
|
+
import { Box, Text } from "ink";
|
|
28
|
+
import { useEffect, useState } from "react";
|
|
29
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
30
|
+
function OpenBrowserView({ problemId, onComplete }) {
|
|
31
|
+
const { status, error, url } = useOpenBrowser({
|
|
32
|
+
problemId,
|
|
33
|
+
onComplete
|
|
34
|
+
});
|
|
35
|
+
if (status === "loading") {
|
|
36
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
37
|
+
/* @__PURE__ */ jsx(Spinner, { label: "\uBE0C\uB77C\uC6B0\uC800\uB97C \uC5EC\uB294 \uC911..." }),
|
|
38
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
39
|
+
"\uBB38\uC81C #",
|
|
40
|
+
problemId
|
|
41
|
+
] }) })
|
|
42
|
+
] });
|
|
43
|
+
}
|
|
44
|
+
if (status === "error") {
|
|
45
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
46
|
+
/* @__PURE__ */ jsxs(Alert, { variant: "error", children: [
|
|
47
|
+
"\uBE0C\uB77C\uC6B0\uC800\uB97C \uC5F4 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ",
|
|
48
|
+
error
|
|
49
|
+
] }),
|
|
50
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
51
|
+
"URL: ",
|
|
52
|
+
url
|
|
53
|
+
] }) })
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
57
|
+
/* @__PURE__ */ jsx(Alert, { variant: "success", children: "\uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C \uBB38\uC81C \uD398\uC774\uC9C0\uB97C \uC5F4\uC5C8\uC2B5\uB2C8\uB2E4!" }),
|
|
58
|
+
/* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
59
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
60
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", bold: true, children: "\uBB38\uC81C \uBC88\uD638:" }),
|
|
61
|
+
" ",
|
|
62
|
+
problemId
|
|
63
|
+
] }),
|
|
64
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
65
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", bold: true, children: "URL:" }),
|
|
66
|
+
" ",
|
|
67
|
+
/* @__PURE__ */ jsx(Text, { color: "blue", underline: true, children: url })
|
|
68
|
+
] })
|
|
69
|
+
] })
|
|
70
|
+
] });
|
|
71
|
+
}
|
|
72
|
+
function SearchView({ query, onComplete }) {
|
|
73
|
+
const [results, setResults] = useState([]);
|
|
74
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
75
|
+
const [totalPages, setTotalPages] = useState(1);
|
|
76
|
+
const [loading, setLoading] = useState(true);
|
|
77
|
+
const [error, setError] = useState(null);
|
|
78
|
+
const [selectedProblemId, setSelectedProblemId] = useState(
|
|
79
|
+
null
|
|
80
|
+
);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
async function performSearch() {
|
|
83
|
+
try {
|
|
84
|
+
setLoading(true);
|
|
85
|
+
setError(null);
|
|
86
|
+
const searchResults = await searchProblems(query, currentPage);
|
|
87
|
+
const resultsWithSolvedStatus = searchResults.problems.map(
|
|
88
|
+
(problem) => {
|
|
89
|
+
const problemDirPath = getProblemDirPath(problem.problemId);
|
|
90
|
+
const isSolved = existsSync(problemDirPath);
|
|
91
|
+
return {
|
|
92
|
+
...problem,
|
|
93
|
+
isSolved
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
setResults(resultsWithSolvedStatus);
|
|
98
|
+
setTotalPages(searchResults.totalPages);
|
|
99
|
+
} catch (err) {
|
|
100
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
101
|
+
} finally {
|
|
102
|
+
setLoading(false);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
void performSearch();
|
|
106
|
+
}, [query, currentPage]);
|
|
107
|
+
if (loading && !selectedProblemId) {
|
|
108
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
109
|
+
/* @__PURE__ */ jsx(Spinner, { label: "\uAC80\uC0C9 \uC911..." }),
|
|
110
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
111
|
+
"\uCFFC\uB9AC: ",
|
|
112
|
+
query
|
|
113
|
+
] }) })
|
|
114
|
+
] });
|
|
115
|
+
}
|
|
116
|
+
if (error && !selectedProblemId) {
|
|
117
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
118
|
+
/* @__PURE__ */ jsxs(Alert, { variant: "error", children: [
|
|
119
|
+
"\uAC80\uC0C9 \uC2E4\uD328: ",
|
|
120
|
+
error
|
|
121
|
+
] }),
|
|
122
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
123
|
+
"\uCFFC\uB9AC: ",
|
|
124
|
+
query
|
|
125
|
+
] }) })
|
|
126
|
+
] });
|
|
127
|
+
}
|
|
128
|
+
if (selectedProblemId) {
|
|
129
|
+
return /* @__PURE__ */ jsx(OpenBrowserView, { problemId: selectedProblemId, onComplete });
|
|
130
|
+
}
|
|
131
|
+
if (results.length === 0) {
|
|
132
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
133
|
+
/* @__PURE__ */ jsx(Alert, { variant: "info", children: "\uAC80\uC0C9 \uACB0\uACFC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4." }),
|
|
134
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
135
|
+
"\uCFFC\uB9AC: ",
|
|
136
|
+
query
|
|
137
|
+
] }) })
|
|
138
|
+
] });
|
|
139
|
+
}
|
|
140
|
+
const options = [];
|
|
141
|
+
results.forEach((problem) => {
|
|
142
|
+
const solvedText = problem.solvedCount ? ` (${problem.solvedCount.toLocaleString()}\uBA85` : "";
|
|
143
|
+
const triesText = problem.averageTries ? `, \uD3C9\uADE0 ${problem.averageTries}\uD68C` : "";
|
|
144
|
+
const suffix = solvedText + triesText + (solvedText ? ")" : "");
|
|
145
|
+
const solvedMark = problem.isSolved ? " \u2713" : "";
|
|
146
|
+
let tierText = "";
|
|
147
|
+
if (problem.level) {
|
|
148
|
+
const tierName = getTierName(problem.level);
|
|
149
|
+
const tierColor = getTierColor(problem.level);
|
|
150
|
+
if (typeof tierColor === "string") {
|
|
151
|
+
tierText = ` ${source_default.bold.hex(tierColor)(tierName)}`;
|
|
152
|
+
} else {
|
|
153
|
+
tierText = ` ${tierColor(source_default.bold(tierName))}`;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
options.push({
|
|
157
|
+
label: `${tierText} ${problem.problemId} - ${problem.title}${solvedMark}${suffix}`,
|
|
158
|
+
value: `problem:${problem.problemId}`
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
if (currentPage < totalPages) {
|
|
162
|
+
options.push({
|
|
163
|
+
label: `\u2192 \uB2E4\uC74C \uD398\uC774\uC9C0 (${currentPage + 1}/${totalPages})`,
|
|
164
|
+
value: "next-page"
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (currentPage > 1) {
|
|
168
|
+
options.push({
|
|
169
|
+
label: `\u2190 \uC774\uC804 \uD398\uC774\uC9C0 (${currentPage - 1}/${totalPages})`,
|
|
170
|
+
value: "prev-page"
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const handleSelect = (value) => {
|
|
174
|
+
if (value === "next-page") {
|
|
175
|
+
setCurrentPage(currentPage + 1);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (value === "prev-page") {
|
|
179
|
+
setCurrentPage(currentPage - 1);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (value.startsWith("problem:")) {
|
|
183
|
+
const problemId = parseInt(value.replace("problem:", ""), 10);
|
|
184
|
+
if (!isNaN(problemId)) {
|
|
185
|
+
setSelectedProblemId(problemId);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
190
|
+
/* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { color: "cyan", bold: true, children: "\u{1F50D} \uAC80\uC0C9 \uACB0\uACFC" }) }),
|
|
191
|
+
/* @__PURE__ */ jsxs(Box, { marginBottom: 1, children: [
|
|
192
|
+
/* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
193
|
+
"\uCFFC\uB9AC: ",
|
|
194
|
+
query
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
197
|
+
" ",
|
|
198
|
+
"(\uD398\uC774\uC9C0 ",
|
|
199
|
+
currentPage,
|
|
200
|
+
"/",
|
|
201
|
+
totalPages,
|
|
202
|
+
")"
|
|
203
|
+
] })
|
|
204
|
+
] }),
|
|
205
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Select, { options, onChange: handleSelect }) })
|
|
206
|
+
] });
|
|
207
|
+
}
|
|
208
|
+
var SearchCommand = class extends Command {
|
|
209
|
+
async execute(args, _flags) {
|
|
210
|
+
const query = args.join(" ").trim();
|
|
211
|
+
if (!query) {
|
|
212
|
+
console.error("\uC624\uB958: \uAC80\uC0C9 \uCFFC\uB9AC\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.");
|
|
213
|
+
console.error(`\uC0AC\uC6A9\uBC95: ps search <\uCFFC\uB9AC>`);
|
|
214
|
+
console.error(`\uB3C4\uC6C0\uB9D0: ps search --help`);
|
|
215
|
+
console.error(`\uC608\uC81C: ps search "*g1...g5"`);
|
|
216
|
+
process.exit(1);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
await this.renderView(SearchView, {
|
|
220
|
+
query
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
SearchCommand = __decorateClass([
|
|
225
|
+
CommandDef({
|
|
226
|
+
name: "search",
|
|
227
|
+
description: `solved.ac\uC5D0\uC11C \uBB38\uC81C\uB97C \uAC80\uC0C9\uD558\uACE0 \uC120\uD0DD\uD55C \uBB38\uC81C\uB97C \uBE0C\uB77C\uC6B0\uC800\uB85C \uC5FD\uB2C8\uB2E4.
|
|
228
|
+
- solved.ac \uAC80\uC0C9\uC5B4 \uBB38\uBC95\uC744 \uC9C0\uC6D0\uD569\uB2C8\uB2E4.
|
|
229
|
+
- \uBB38\uC81C \uBAA9\uB85D\uC5D0\uC11C \uC120\uD0DD\uD558\uBA74 \uC790\uB3D9\uC73C\uB85C \uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C \uBB38\uC81C \uD398\uC774\uC9C0\uB97C \uC5FD\uB2C8\uB2E4.
|
|
230
|
+
- \uD398\uC774\uC9C0\uB124\uC774\uC158\uC744 \uD1B5\uD574 \uC5EC\uB7EC \uD398\uC774\uC9C0\uC758 \uACB0\uACFC\uB97C \uD0D0\uC0C9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`,
|
|
231
|
+
autoDetectProblemId: false,
|
|
232
|
+
requireProblemId: false,
|
|
233
|
+
examples: [
|
|
234
|
+
'search "*g1...g5" # Gold 1-5 \uBB38\uC81C \uAC80\uC0C9',
|
|
235
|
+
'search "tier:g1...g5" # Gold 1-5 \uBB38\uC81C \uAC80\uC0C9 (tier: \uBB38\uBC95)',
|
|
236
|
+
'search "#dp" # DP \uD0DC\uADF8 \uBB38\uC81C \uAC80\uC0C9',
|
|
237
|
+
'search "tag:dp" # DP \uD0DC\uADF8 \uBB38\uC81C \uAC80\uC0C9 (tag: \uBB38\uBC95)',
|
|
238
|
+
'search "*g1...g5 #dp" # Gold 1-5 \uD2F0\uC5B4\uC758 DP \uD0DC\uADF8 \uBB38\uC81C \uAC80\uC0C9'
|
|
239
|
+
]
|
|
240
|
+
})
|
|
241
|
+
], SearchCommand);
|
|
242
|
+
var search_default = CommandBuilder.fromClass(SearchCommand);
|
|
243
|
+
export {
|
|
244
|
+
SearchCommand,
|
|
245
|
+
search_default as default
|
|
246
|
+
};
|