node-csfd-api 5.6.0-next.0 → 5.6.0-next.2
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/cli.js +19 -6
- package/package.js +1 -1
- package/package.json +5 -2
package/cli.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
//#region src/cli.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
function getCommandName() {
|
|
4
|
+
const scriptPath = process.argv[1] ?? "";
|
|
5
|
+
const basename = scriptPath.split("/").pop() ?? "";
|
|
6
|
+
if (basename === "csfd" || basename === "node-csfd-api") return basename;
|
|
7
|
+
if (scriptPath.includes("node-csfd-api")) return "npx node-csfd-api";
|
|
8
|
+
return "csfd";
|
|
9
|
+
}
|
|
6
10
|
async function main() {
|
|
7
11
|
const args = process.argv.slice(2);
|
|
8
12
|
switch (args[0]) {
|
|
@@ -29,7 +33,7 @@ async function main() {
|
|
|
29
33
|
const userId = Number(userIdRaw);
|
|
30
34
|
if (!userIdRaw || isNaN(userId)) {
|
|
31
35
|
console.error("Error: Please provide a valid numeric User ID.");
|
|
32
|
-
console.log(
|
|
36
|
+
console.log(`Usage: ${getCommandName()} export ratings <userId> [options]`);
|
|
33
37
|
process.exit(1);
|
|
34
38
|
}
|
|
35
39
|
const isLetterboxd = args.includes("--letterboxd");
|
|
@@ -55,7 +59,7 @@ async function main() {
|
|
|
55
59
|
}
|
|
56
60
|
} else if (args[1] === "letterboxd") {
|
|
57
61
|
console.warn("Deprecation Warning: \"export letterboxd\" is deprecated. Please use \"export ratings <id> --letterboxd\" instead.");
|
|
58
|
-
console.log(
|
|
62
|
+
console.log(`Usage: ${getCommandName()} export ratings <userId> --letterboxd`);
|
|
59
63
|
process.exit(1);
|
|
60
64
|
} else {
|
|
61
65
|
console.error(`Unknown export target: ${args[1]}`);
|
|
@@ -63,14 +67,19 @@ async function main() {
|
|
|
63
67
|
process.exit(1);
|
|
64
68
|
}
|
|
65
69
|
break;
|
|
70
|
+
case "--version":
|
|
71
|
+
case "-v":
|
|
72
|
+
console.log("5.6.0-next.2");
|
|
73
|
+
break;
|
|
66
74
|
default:
|
|
67
75
|
printUsage();
|
|
68
76
|
break;
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
79
|
function printUsage() {
|
|
80
|
+
const cmd = getCommandName();
|
|
72
81
|
console.log(`
|
|
73
|
-
Usage:
|
|
82
|
+
Usage: ${cmd} <command> [options]
|
|
74
83
|
|
|
75
84
|
Commands:
|
|
76
85
|
server, api Start the REST API server
|
|
@@ -81,6 +90,10 @@ Commands:
|
|
|
81
90
|
--json Export to JSON format
|
|
82
91
|
--letterboxd Export to Letterboxd-compatible CSV format
|
|
83
92
|
help Show this help message
|
|
93
|
+
|
|
94
|
+
Flags:
|
|
95
|
+
--version, -v Show version
|
|
96
|
+
--help, -h Show this help message
|
|
84
97
|
`);
|
|
85
98
|
}
|
|
86
99
|
main().catch((error) => {
|
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-csfd-api",
|
|
3
|
-
"version": "5.6.0-next.
|
|
3
|
+
"version": "5.6.0-next.2",
|
|
4
4
|
"description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
|
|
5
5
|
"author": "BART! <bart@bartweb.cz>",
|
|
6
6
|
"publishConfig": {
|
|
@@ -63,6 +63,9 @@
|
|
|
63
63
|
},
|
|
64
64
|
"./package.json": "./package.json"
|
|
65
65
|
},
|
|
66
|
-
"bin":
|
|
66
|
+
"bin": {
|
|
67
|
+
"csfd": "cli.js",
|
|
68
|
+
"node-csfd-api": "cli.js"
|
|
69
|
+
},
|
|
67
70
|
"sideEffects": false
|
|
68
71
|
}
|