lscontests 1.8.3 → 1.8.4
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/cli.js +21 -18
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
@@ -15,36 +15,39 @@ const package_json_1 = require("../package.json");
|
|
15
15
|
const commander_1 = require("commander");
|
16
16
|
const oj_1 = require("./lib/oj");
|
17
17
|
const _1 = require(".");
|
18
|
-
|
19
|
-
.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
function initCmd() {
|
19
|
+
return new commander_1.Command()
|
20
|
+
.name("lsct")
|
21
|
+
.version(package_json_1.version)
|
22
|
+
.option("-d, --days, <day>", "Number of days to get contests information", "3")
|
23
|
+
.option("-l, --list", "List all supported OJ")
|
24
|
+
.addOption(new commander_1.Option("-o, --oj <ojs...>", "OJs to get contests information").choices(Object.keys(oj_1.alloj)))
|
25
|
+
.addOption(new commander_1.Option("-r, --raw", "Print raw contest list").conflicts("language"))
|
26
|
+
.addOption(new commander_1.Option("-L, --language <lang>", "Set output language").default("zh-CN").choices(_1.langList))
|
27
|
+
.option("--no-sort", "Do not sort by contests start time, but by OJ order");
|
28
|
+
}
|
27
29
|
function cli(arg) {
|
28
30
|
return __awaiter(this, void 0, void 0, function* () {
|
29
|
-
|
31
|
+
const cmd = initCmd();
|
30
32
|
if (arg) {
|
33
|
+
let msg = "";
|
31
34
|
try {
|
32
|
-
|
35
|
+
cmd
|
33
36
|
.configureOutput({
|
34
|
-
writeOut: (str) =>
|
35
|
-
writeErr: (str) =>
|
36
|
-
outputError: (str) =>
|
37
|
+
writeOut: (str) => msg = str,
|
38
|
+
writeErr: (str) => msg = str,
|
39
|
+
outputError: (str) => msg = str
|
37
40
|
})
|
38
41
|
.exitOverride()
|
39
42
|
.parse(arg.split(" "), { from: "user" });
|
40
43
|
}
|
41
44
|
catch (e) {
|
42
|
-
return
|
45
|
+
return msg;
|
43
46
|
}
|
44
47
|
}
|
45
48
|
else
|
46
|
-
|
47
|
-
const opts =
|
49
|
+
cmd.parse();
|
50
|
+
const opts = cmd.opts();
|
48
51
|
if (opts.list)
|
49
52
|
return Object.values(oj_1.alloj).map((oj) => oj.name).join("\n");
|
50
53
|
else {
|
@@ -54,7 +57,7 @@ function cli(arg) {
|
|
54
57
|
sort: opts.sort
|
55
58
|
};
|
56
59
|
if (opts.raw)
|
57
|
-
return (yield (0, _1.getContestList)(config))
|
60
|
+
return JSON.stringify(yield (0, _1.getContestList)(config), null, 2);
|
58
61
|
else
|
59
62
|
return yield (0, _1.getContestInfo)(config, opts.language);
|
60
63
|
}
|
package/dist/cli.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,kDAA0C;AAC1C,yCAA4C;AAC5C,iCAAiC;AACjC,wBAAqE;AAErE,mBAAO;
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,kDAA0C;AAC1C,yCAA4C;AAC5C,iCAAiC;AACjC,wBAAqE;AAErE,SAAS,OAAO;IAEZ,OAAO,IAAI,mBAAO,EAAE;SACf,IAAI,CAAC,MAAM,CAAC;SACZ,OAAO,CAAC,sBAAO,CAAC;SAChB,MAAM,CAAC,mBAAmB,EAAE,4CAA4C,EAAE,GAAG,CAAC;SAC9E,MAAM,CAAC,YAAY,EAAE,uBAAuB,CAAC;SAC7C,SAAS,CAAC,IAAI,kBAAM,CAAC,mBAAmB,EAAE,iCAAiC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAK,CAAC,CAAC,CAAC;SACzG,SAAS,CAAC,IAAI,kBAAM,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;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