libroadcast-cli 1.5.0 → 1.7.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/README.md CHANGED
@@ -23,7 +23,7 @@ Commands:
23
23
  Note: The delay is specified in seconds. (max 3600 seconds = 1 hour)
24
24
  Options:
25
25
  --onlyDelay Set only the delay without changing the start time.
26
- --noDelay Remove the delay from the rounds.
26
+ --noDelay Do not modify the delay, only adjust the start time.
27
27
 
28
28
  setPGN <broadcastId> <sourcePGNUrl> [--withFilter] [--slice <sliceFilter>]
29
29
  Sets the source PGN URL for all rounds in the specified broadcast.
@@ -37,6 +37,12 @@ Commands:
37
37
  Sets the games for the specified broadcast round using Lichess game IDs.
38
38
  Note: Maximum of 64 game IDs can be provided.
39
39
 
40
+ fixSchedule <broadcastId> <timeDiff> [--rounds <roundsToFix>]
41
+ Fixes the schedule of rounds in the specified broadcast by applying a time difference.
42
+ Note: The time difference should be in a format like "1h", "30m", "15s", etc.
43
+ Options:
44
+ --rounds <roundsToFix> Specify which rounds to fix using formats like '1-4', '8+', '3,5,7', etc.
45
+
40
46
 
41
47
  Examples:
42
48
  # Set a 5-minute delay without changing start time
@@ -44,5 +50,7 @@ Examples:
44
50
  # Set source PGN URL with round and slice filters
45
51
  $ setPGN bcast123 https://example.com/pgns/round-{}/game.pgn --withFilter --slice "1-5,7,9-12"
46
52
  # Set Lichess games for a broadcast round
47
- $ setLichessGames round456 gameId1 gameId2 gameId3
53
+ $ setLichessGames round456 gameId1 gameId2 gameId3
54
+ # Fix schedule of rounds 1 to 4 and all rounds after 8 by adding 15 minutes
55
+ $ fixSchedule bcast123 15m --rounds 1-4,8+
48
56
  ```
package/dist/cmd/delay.js CHANGED
@@ -10,8 +10,7 @@ const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
10
10
  const colors_1 = __importDefault(require("../utils/colors"));
11
11
  const setDelayRounds = async (rounds, delay, onlyDelay, noDelay) => {
12
12
  for (const round of rounds) {
13
- await commandHandler_1.client
14
- .POST("/broadcast/round/{broadcastRoundId}/edit", {
13
+ await (0, commandHandler_1.handleApiResponse)(commandHandler_1.client.POST("/broadcast/round/{broadcastRoundId}/edit", {
15
14
  params: {
16
15
  path: { broadcastRoundId: round.id },
17
16
  query: { patch: 1 },
@@ -22,16 +21,7 @@ const setDelayRounds = async (rounds, delay, onlyDelay, noDelay) => {
22
21
  ? round.startsAt + delay * 1000
23
22
  : undefined,
24
23
  },
25
- })
26
- .then((response) => {
27
- if (response.response.ok)
28
- console.log(colors_1.default.green(`Successfully set delay for round ${colors_1.default.whiteBold(round.id)} to ${colors_1.default.whiteBold(delay.toString())} seconds.`));
29
- else
30
- console.error(colors_1.default.red(`Failed to set delay for round ${colors_1.default.whiteBold(round.id)}: ${colors_1.default.whiteBold(response.response.statusText)}`));
31
- })
32
- .catch((error) => {
33
- console.error(colors_1.default.red(`Error setting delay for round ${colors_1.default.whiteBold(round.id)}:`), error);
34
- });
24
+ }), `Successfully set delay for round ${colors_1.default.whiteBold(round.id)} to ${colors_1.default.whiteBold(delay.toString())} seconds.`, `Error setting delay for round ${colors_1.default.whiteBold(round.id)}`);
35
25
  await (0, commandHandler_1.sleep)(200);
36
26
  }
37
27
  };
@@ -42,7 +32,7 @@ const delayCommand = async (args) => {
42
32
  (0, node_process_1.exit)(1);
43
33
  }
44
34
  const delayNum = parseInt(delay, 10);
45
- if (isNaN(delayNum) && delayNum >= 0 && delayNum <= 3600) {
35
+ if (isNaN(delayNum) || delayNum < 0 || delayNum > 3600) {
46
36
  (0, commandHandler_1.msgCommonErrorHelp)("Delay must be a number between 0 and 3600 seconds.");
47
37
  (0, node_process_1.exit)(1);
48
38
  }
@@ -57,6 +47,6 @@ const delayCommand = async (args) => {
57
47
  console.error(colors_1.default.red("No rounds found for the specified broadcast."));
58
48
  (0, node_process_1.exit)(1);
59
49
  }
60
- setDelayRounds(broadcast.rounds, parseInt(delay, 10), onlyDelay, noDelay);
50
+ await setDelayRounds(broadcast.rounds, delayNum, onlyDelay, noDelay);
61
51
  };
62
52
  exports.delayCommand = delayCommand;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fixScheduleCommand = void 0;
7
+ const node_process_1 = require("node:process");
8
+ const commandHandler_1 = require("../utils/commandHandler");
9
+ const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
10
+ const colors_1 = __importDefault(require("../utils/colors"));
11
+ const ms_1 = require("ms");
12
+ const fixScheduleRounds = async (rounds, timeDiff, roundsToFix) => {
13
+ rounds = rounds
14
+ .filter((_, i) => !roundsToFix?.length || roundsToFix.includes(i + 1))
15
+ .filter((el) => el.startsAt !== undefined);
16
+ if (rounds.length === 0) {
17
+ console.error(colors_1.default.red("No rounds to fix after applying filters."));
18
+ (0, node_process_1.exit)(1);
19
+ }
20
+ for (const round of rounds) {
21
+ await (0, commandHandler_1.handleApiResponse)(commandHandler_1.client.POST("/broadcast/round/{broadcastRoundId}/edit", {
22
+ params: {
23
+ path: { broadcastRoundId: round.id },
24
+ query: { patch: 1 },
25
+ },
26
+ body: {
27
+ startsAt: round.startsAt + timeDiff,
28
+ },
29
+ }), `Successfully fixed schedule for round ${colors_1.default.whiteBold(round.id)}.`, `Error fixing schedule for round ${colors_1.default.whiteBold(round.id)}`);
30
+ await (0, commandHandler_1.sleep)(200);
31
+ }
32
+ };
33
+ const translateRoundsToFix = (arg) => {
34
+ const rounds = [];
35
+ const parts = arg.split(",");
36
+ for (const part of parts) {
37
+ if (part.endsWith("+")) {
38
+ const start = parseInt(part.slice(0, -1), 10);
39
+ if (isNaN(start))
40
+ continue;
41
+ for (let i = start; i <= 64; i++) {
42
+ rounds.push(i);
43
+ }
44
+ }
45
+ else if (part.includes("-")) {
46
+ const [startStr, endStr] = part.split("-");
47
+ const start = parseInt(startStr, 10);
48
+ const end = parseInt(endStr, 10);
49
+ if (isNaN(start) || isNaN(end))
50
+ continue;
51
+ for (let i = start; i <= end; i++) {
52
+ rounds.push(i);
53
+ }
54
+ }
55
+ else {
56
+ const roundNum = parseInt(part, 10);
57
+ if (isNaN(roundNum))
58
+ continue;
59
+ rounds.push(roundNum);
60
+ }
61
+ }
62
+ return [...new Set(rounds)];
63
+ };
64
+ const fixScheduleCommand = async (args) => {
65
+ const [broadcastId, timeDiffStr] = args.slice(0, 2);
66
+ if (!broadcastId || !timeDiffStr) {
67
+ (0, commandHandler_1.msgCommonErrorHelp)("Broadcast ID and time difference are required.");
68
+ (0, node_process_1.exit)(1);
69
+ }
70
+ const timeDiff = (0, ms_1.parse)(timeDiffStr);
71
+ if (isNaN(timeDiff)) {
72
+ console.error(colors_1.default.red("Error: Time difference must be a valid duration string (e.g., '1h', '30m', '15s')."));
73
+ (0, node_process_1.exit)(1);
74
+ }
75
+ console.log(`Applying time difference of ${colors_1.default.whiteBold(timeDiffStr)} (${colors_1.default.whiteBold(timeDiff.toString())} ms) to broadcast ${colors_1.default.whiteBold(broadcastId)}.`);
76
+ const roundsArgIndex = args.findIndex((arg) => arg === "--rounds");
77
+ let roundsToFix = undefined;
78
+ if (roundsArgIndex !== -1 && roundsArgIndex + 1 < args.length) {
79
+ const roundsArg = args[roundsArgIndex + 1];
80
+ roundsToFix = roundsArg ? translateRoundsToFix(roundsArg) : undefined;
81
+ }
82
+ const broadcast = await (0, getInfoBroadcast_1.getBroadcast)(broadcastId);
83
+ if (!broadcast?.rounds || broadcast.rounds.length === 0) {
84
+ console.error(colors_1.default.red(`Broadcast with ID ${colors_1.default.whiteBold(broadcastId)} not found or has no rounds.`));
85
+ (0, node_process_1.exit)(1);
86
+ }
87
+ await fixScheduleRounds(broadcast.rounds, timeDiff, roundsToFix);
88
+ };
89
+ exports.fixScheduleCommand = fixScheduleCommand;
@@ -8,8 +8,7 @@ const node_process_1 = require("node:process");
8
8
  const commandHandler_1 = require("../utils/commandHandler");
9
9
  const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
10
10
  const colors_1 = __importDefault(require("../utils/colors"));
11
- const setLichessGames = (round, games) => commandHandler_1.client
12
- .POST("/broadcast/round/{broadcastRoundId}/edit", {
11
+ const setLichessGames = (round, games) => (0, commandHandler_1.handleApiResponse)(commandHandler_1.client.POST("/broadcast/round/{broadcastRoundId}/edit", {
13
12
  params: {
14
13
  path: { broadcastRoundId: round.id },
15
14
  query: { patch: 1 },
@@ -18,16 +17,7 @@ const setLichessGames = (round, games) => commandHandler_1.client
18
17
  syncSource: "ids",
19
18
  syncIds: games,
20
19
  },
21
- })
22
- .then((response) => {
23
- if (response.response.ok)
24
- console.log(colors_1.default.green(`Successfully set games for round ${colors_1.default.whiteBold(round.id)} to ${colors_1.default.whiteBold(games)}.`));
25
- else
26
- console.error(colors_1.default.red(`Failed to set games for round ${colors_1.default.whiteBold(round.id)}: ${colors_1.default.whiteBold(response.response.statusText)}`));
27
- })
28
- .catch((error) => {
29
- console.error(colors_1.default.red(`Error setting games for round ${colors_1.default.whiteBold(round.id)}:`), error);
30
- });
20
+ }), `Successfully set games for round ${colors_1.default.whiteBold(round.id)} to ${colors_1.default.whiteBold(games)}.`, `Error setting games for round ${colors_1.default.whiteBold(round.id)}`);
31
21
  const setLichessGamesCommand = async (args) => {
32
22
  const bId = args.shift();
33
23
  const games = args.slice(0, 64).join(" ");
@@ -40,6 +30,6 @@ const setLichessGamesCommand = async (args) => {
40
30
  console.error(colors_1.default.red(`Broadcast round with ID ${colors_1.default.whiteBold(bId)} not found or has no rounds.`));
41
31
  (0, node_process_1.exit)(1);
42
32
  }
43
- setLichessGames(round, games);
33
+ await setLichessGames(round, games);
44
34
  };
45
35
  exports.setLichessGamesCommand = setLichessGamesCommand;
@@ -9,11 +9,10 @@ const commandHandler_1 = require("../utils/commandHandler");
9
9
  const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
10
10
  const colors_1 = __importDefault(require("../utils/colors"));
11
11
  const setPGN = async (rounds, urlRound, setRoundFilter, setSliceFilter = null) => {
12
- for (let rN = 1; rN <= rounds.length; rN++) {
13
- const round = rounds[rN - 1];
12
+ for (const [index, round] of rounds.entries()) {
13
+ const rN = index + 1;
14
14
  const url = urlRound(rN);
15
- await commandHandler_1.client
16
- .POST("/broadcast/round/{broadcastRoundId}/edit", {
15
+ await (0, commandHandler_1.handleApiResponse)(commandHandler_1.client.POST("/broadcast/round/{broadcastRoundId}/edit", {
17
16
  params: {
18
17
  path: { broadcastRoundId: round.id },
19
18
  query: { patch: 1 },
@@ -22,18 +21,9 @@ const setPGN = async (rounds, urlRound, setRoundFilter, setSliceFilter = null) =
22
21
  syncSource: "url",
23
22
  syncUrl: url,
24
23
  onlyRound: setRoundFilter ? rN : undefined,
25
- slices: setSliceFilter ? setSliceFilter : undefined,
24
+ slices: setSliceFilter || undefined,
26
25
  },
27
- })
28
- .then((response) => {
29
- if (response.response.ok)
30
- console.log(colors_1.default.green(`Successfully set source for round ${colors_1.default.whiteBold(round.id)} to ${colors_1.default.whiteBold(url)}.`));
31
- else
32
- console.error(colors_1.default.red(`Failed to set source for round ${colors_1.default.whiteBold(round.id)}: ${colors_1.default.whiteBold(response.response.statusText)}`));
33
- })
34
- .catch((error) => {
35
- console.error(colors_1.default.red(`Error setting source for round ${colors_1.default.whiteBold(round.id)}:`), error);
36
- });
26
+ }), `Successfully set source for round ${colors_1.default.whiteBold(round.id)} to ${colors_1.default.whiteBold(url)}.`, `Error setting source for round ${colors_1.default.whiteBold(round.id)}`);
37
27
  await (0, commandHandler_1.sleep)(200);
38
28
  }
39
29
  };
@@ -49,27 +39,24 @@ const setPGNCommand = async (args) => {
49
39
  (0, node_process_1.exit)(1);
50
40
  }
51
41
  const urlRound = (roundNum) => roundNum ? sourcePGN.replaceAll("{}", roundNum.toString()) : sourcePGN;
52
- let isLCC = false;
53
42
  try {
54
43
  const url = new URL(urlRound());
55
- if (!url.protocol.startsWith("http"))
56
- throw new Error();
57
- isLCC = url.hostname === "view.livechesscloud.com";
58
- if (isLCC && url.hash.length > 1 && !url.hash.endsWith("/{}"))
59
- throw new Error();
44
+ if (!url.protocol.startsWith("http")) {
45
+ throw new Error("Invalid protocol");
46
+ }
47
+ const isLCC = url.hostname === "view.livechesscloud.com";
48
+ if (isLCC && url.hash.length > 1 && !url.hash.endsWith("/{}")) {
49
+ console.error(colors_1.default.red('Invalid URL. For livechesscloud URLs, please ensure it ends with "/{}".'));
50
+ (0, node_process_1.exit)(1);
51
+ }
60
52
  }
61
- catch {
62
- console.error(colors_1.default.red(isLCC
63
- ? 'Invalid URL. For livechesscloud URLs, please ensure it ends with "/{}".'
64
- : 'Invalid URL. Must be http/https with "{}" as round placeholder.'));
53
+ catch (error) {
54
+ console.error(colors_1.default.red('Invalid URL. Must be http/https with "{}" as round placeholder.'));
65
55
  (0, node_process_1.exit)(1);
66
56
  }
67
57
  const setRoundFilter = args.includes("--withFilter");
68
58
  const sliceIndex = args.indexOf("--slice");
69
- let setSliceFilter = null;
70
- if (sliceIndex !== -1 && args.length > sliceIndex + 1) {
71
- setSliceFilter = args[sliceIndex + 1];
72
- }
73
- setPGN(bcast.rounds, urlRound, setRoundFilter, setSliceFilter);
59
+ const setSliceFilter = sliceIndex !== -1 ? args[sliceIndex + 1] || null : null;
60
+ await setPGN(bcast.rounds, urlRound, setRoundFilter, setSliceFilter);
74
61
  };
75
62
  exports.setPGNCommand = setPGNCommand;
package/dist/index.js CHANGED
@@ -1,13 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
7
  const node_process_1 = require("node:process");
8
+ const node_fs_1 = require("node:fs");
9
+ const node_path_1 = require("node:path");
5
10
  const commandHandler_1 = require("./utils/commandHandler");
6
11
  const help_1 = require("./utils/help");
12
+ const colors_1 = __importDefault(require("./utils/colors"));
7
13
  (async () => {
8
14
  if (commandHandler_1.args.includes("--version") || commandHandler_1.args.includes("-v")) {
9
- const { version } = require("../package.json");
10
- console.log(`libroadcast-cli v${version}`);
15
+ const packageJson = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, "../package.json"), "utf-8"));
16
+ console.log(`${colors_1.default.whiteBold("libroadcast-cli")} ${colors_1.default.underItalic(`v${packageJson.version}`)}`);
11
17
  (0, node_process_1.exit)(0);
12
18
  }
13
19
  if (commandHandler_1.args.length === 0 || (0, help_1.includeHelp)(commandHandler_1.args[0])) {
@@ -16,18 +22,16 @@ const help_1 = require("./utils/help");
16
22
  }
17
23
  const cmd = commandHandler_1.args.shift();
18
24
  const handler = commandHandler_1.commands.get(cmd);
19
- if (cmd === commandHandler_1.Command.SetLCC)
20
- console.warn("Warning: 'setLCC' command was removed. Will use 'setPGN' instead.");
21
25
  if (commandHandler_1.args.find(help_1.includeHelp)) {
22
26
  (0, help_1.showHelp)(cmd);
23
27
  (0, node_process_1.exit)(0);
24
28
  }
25
29
  if (!handler) {
26
- console.error("Error: Command handler not found.");
30
+ console.error(`${colors_1.default.red("Error:")} Command handler not found.`);
27
31
  (0, node_process_1.exit)(1);
28
32
  }
29
- if (!commandHandler_1.LICHESS_TOKEN) {
30
- console.error("Error: LICHESS_TOKEN environment variable is not set.");
33
+ if (!commandHandler_1.LICHESS_TOKEN?.trim() || !commandHandler_1.LICHESS_TOKEN.startsWith("lip_")) {
34
+ console.error(`${colors_1.default.red("Error:")} ${colors_1.default.whiteBold("LICHESS_TOKEN")} environment variable is not set, empty, or invalid (must start with 'lip_').`);
31
35
  (0, node_process_1.exit)(1);
32
36
  }
33
37
  await handler(commandHandler_1.args);
@@ -3,28 +3,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.msgCommonErrorHelp = exports.sleep = exports.client = exports.commands = exports.Command = exports.args = exports.LICHESS_TOKEN = void 0;
6
+ exports.handleApiResponse = exports.msgCommonErrorHelp = exports.sleep = exports.client = exports.commands = exports.Command = exports.args = exports.LICHESS_TOKEN = void 0;
7
7
  const node_process_1 = require("node:process");
8
8
  const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
9
9
  const delay_1 = require("../cmd/delay");
10
10
  const setPGN_1 = require("../cmd/setPGN");
11
11
  const setLichessGames_1 = require("../cmd/setLichessGames");
12
+ const fixSchedule_1 = require("../cmd/fixSchedule");
12
13
  const colors_1 = __importDefault(require("./colors"));
13
14
  exports.LICHESS_TOKEN = node_process_1.env.LICHESS_TOKEN;
14
- const LICHESS_DOMAIN = node_process_1.env.LICHESS_DOMAIN || "https://lichess.org/";
15
+ const LICHESS_DOMAIN = (node_process_1.env.LICHESS_DOMAIN || "https://lichess.org").replace(/\/$/, "") + "/";
15
16
  exports.args = node_process_1.argv.slice(2);
16
17
  var Command;
17
18
  (function (Command) {
18
19
  Command["Delay"] = "delay";
19
- Command["SetLCC"] = "setLCC";
20
20
  Command["SetPGN"] = "setPGN";
21
21
  Command["SetLichessGames"] = "setLichessGames";
22
+ Command["FixSchedule"] = "fixSchedule";
22
23
  })(Command || (exports.Command = Command = {}));
23
24
  exports.commands = new Map([
24
25
  [Command.Delay, delay_1.delayCommand],
25
- [Command.SetLCC, setPGN_1.setPGNCommand],
26
26
  [Command.SetPGN, setPGN_1.setPGNCommand],
27
27
  [Command.SetLichessGames, setLichessGames_1.setLichessGamesCommand],
28
+ [Command.FixSchedule, fixSchedule_1.fixScheduleCommand],
28
29
  ]);
29
30
  exports.client = (0, openapi_fetch_1.default)({
30
31
  baseUrl: LICHESS_DOMAIN,
@@ -40,3 +41,18 @@ const msgCommonErrorHelp = (msg) => {
40
41
  console.info(colors_1.default.blue("Use --help to see usage."));
41
42
  };
42
43
  exports.msgCommonErrorHelp = msgCommonErrorHelp;
44
+ const handleApiResponse = async (promise, successMsg, errorContext) => {
45
+ try {
46
+ const response = await promise;
47
+ if (response.response.ok) {
48
+ console.log(colors_1.default.green(successMsg));
49
+ }
50
+ else {
51
+ console.error(colors_1.default.red(`${errorContext}: ${colors_1.default.whiteBold(response.response.statusText)}`));
52
+ }
53
+ }
54
+ catch (error) {
55
+ console.error(colors_1.default.red(errorContext), error);
56
+ }
57
+ };
58
+ exports.handleApiResponse = handleApiResponse;
@@ -6,18 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.includeHelp = exports.showHelp = void 0;
7
7
  const commandHandler_1 = require("./commandHandler");
8
8
  const colors_1 = __importDefault(require("./colors"));
9
- const msg = [
10
- `${colors_1.default.boldYellow("Usage:")} ${colors_1.default.underItalic("<command> [options]")}`,
11
- ``,
12
- ``,
13
- `${colors_1.default.boldYellow("Commands:")}`,
9
+ const helpDelay = [
14
10
  ` ${colors_1.default.underItalic("delay <broadcastId> <delayInSeconds> [--onlyDelay] [--noDelay]")}`,
15
11
  ` ${colors_1.default.gray("Sets the delay for all rounds in the specified broadcast.")}`,
16
12
  ` ${colors_1.default.bold("Note:")} ${colors_1.default.gray("The delay is specified in seconds. (max 3600 seconds = 1 hour)")}`,
17
13
  ` ${colors_1.default.bold("Options:")}`,
18
14
  ` --onlyDelay ${colors_1.default.gray("Set only the delay without changing the start time.")}`,
19
- ` --noDelay ${colors_1.default.gray("Remove the delay from the rounds.")}`,
20
- ``,
15
+ ` --noDelay ${colors_1.default.gray("Do not modify the delay, only adjust the start time.")}`,
16
+ ].join("\n");
17
+ const helpSetPGN = [
21
18
  ` ${colors_1.default.underItalic("setPGN <broadcastId> <sourcePGNUrl> [--withFilter] [--slice <sliceFilter>]")}`,
22
19
  ` ${colors_1.default.gray("Sets the source PGN URL for all rounds in the specified broadcast.")}`,
23
20
  ` ${colors_1.default.italic("(optional)")} ${colors_1.default.gray('Use "{}" in the URL as a placeholder for the round number.')}`,
@@ -25,10 +22,31 @@ const msg = [
25
22
  ` ${colors_1.default.bold("Options:")}`,
26
23
  ` --withFilter ${colors_1.default.gray("Apply round number filtering based on round number.")}`,
27
24
  ` --slice <sliceFilter> ${colors_1.default.gray("Apply slice filtering using the provided filter string.")}`,
28
- ``,
25
+ ].join("\n");
26
+ const helpSetLichessGames = [
29
27
  ` ${colors_1.default.underItalic("setLichessGames <broadcastRoundId> <gameIds...>")}`,
30
28
  ` ${colors_1.default.gray("Sets the games for the specified broadcast round using Lichess game IDs.")}`,
31
29
  ` ${colors_1.default.bold("Note:")} ${colors_1.default.gray("Maximum of 64 game IDs can be provided.")}`,
30
+ ].join("\n");
31
+ const helpFixSchedule = [
32
+ ` ${colors_1.default.underItalic("fixSchedule <broadcastId> <timeDiff> [--rounds <roundsToFix>]")}`,
33
+ ` ${colors_1.default.gray("Fixes the schedule of rounds in the specified broadcast by applying a time difference.")}`,
34
+ ` ${colors_1.default.bold("Note:")} ${colors_1.default.gray('The time difference should be in a format like "1h", "30m", "15s", etc.')}`,
35
+ ` ${colors_1.default.bold("Options:")}`,
36
+ ` --rounds <roundsToFix> ${colors_1.default.gray("Specify which rounds to fix using formats like '1-4', '8+', '3,5,7', etc.")}`,
37
+ ].join("\n");
38
+ const msg = [
39
+ `${colors_1.default.boldYellow("Usage:")} ${colors_1.default.underItalic("<command> [options]")}`,
40
+ ``,
41
+ ``,
42
+ `${colors_1.default.boldYellow("Commands:")}`,
43
+ helpDelay,
44
+ ``,
45
+ helpSetPGN,
46
+ ``,
47
+ helpSetLichessGames,
48
+ ``,
49
+ helpFixSchedule,
32
50
  ``,
33
51
  ``,
34
52
  `${colors_1.default.boldYellow("Examples:")}`,
@@ -38,19 +56,18 @@ const msg = [
38
56
  ` $ ${colors_1.default.underItalic("setPGN")} ${colors_1.default.italic('bcast123 https://example.com/pgns/round-{}/game.pgn --withFilter --slice "1-5,7,9-12"')}`,
39
57
  ` ${colors_1.default.gray("# Set Lichess games for a broadcast round")}`,
40
58
  ` $ ${colors_1.default.underItalic("setLichessGames")} ${colors_1.default.italic("round456 gameId1 gameId2 gameId3")}`,
59
+ ` ${colors_1.default.gray("# Fix schedule of rounds 1 to 4 and all rounds after 8 by adding 15 minutes")}`,
60
+ ` $ ${colors_1.default.underItalic("fixSchedule")} ${colors_1.default.italic("bcast123 15m --rounds 1-4,8+")}`,
41
61
  ];
42
62
  const showHelp = (cmd) => {
43
63
  const ranges = {
44
- [commandHandler_1.Command.Delay]: [4, 10],
45
- [commandHandler_1.Command.SetPGN]: [11, 18],
46
- [commandHandler_1.Command.SetLCC]: [11, 18],
47
- [commandHandler_1.Command.SetLichessGames]: [19, 22],
64
+ [commandHandler_1.Command.Delay]: helpDelay,
65
+ [commandHandler_1.Command.SetPGN]: helpSetPGN,
66
+ [commandHandler_1.Command.SetLichessGames]: helpSetLichessGames,
67
+ [commandHandler_1.Command.FixSchedule]: helpFixSchedule,
48
68
  };
49
69
  const range = cmd ? ranges[cmd] : undefined;
50
- if (cmd === commandHandler_1.Command.SetLCC) {
51
- console.warn("Warning: 'setLCC' command was removed. Use 'setPGN' command instead.");
52
- }
53
- console.info(range ? msg.slice(...range).join("\n") : msg.join("\n"));
70
+ console.info(range ? range : msg.join("\n"));
54
71
  };
55
72
  exports.showHelp = showHelp;
56
73
  const includeHelp = (str) => ["--help", "-h"].includes(str);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libroadcast-cli",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "CLI to help with broadcast maintenance on Lichess",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [
@@ -14,6 +14,7 @@
14
14
  "dependencies": {
15
15
  "@lichess-org/types": "^2.0.94",
16
16
  "@types/node": "^24.10.0",
17
+ "ms": "3.0.0-canary.202508261828",
17
18
  "openapi-fetch": "^0.15.0"
18
19
  },
19
20
  "devDependencies": {