refactor(參數): parseIndex 抽到 lib,四支腳本共用

同一段 /^[1-9]\d*$/ 與 BAD_INDEX 已經抄了四份。lib 本來就放著同性質的 parseRepo,
這一支該待在它旁邊。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-17 14:05:19 +08:00
co-authored by Claude Opus 5
parent dfa7edc275
commit c8f7ab42f2
5 changed files with 17 additions and 24 deletions
+1 -6
View File
@@ -16,6 +16,7 @@ import {
main,
pages,
parseFlags,
parseIndex,
parseRepo,
preflight,
resolveLogin,
@@ -70,12 +71,6 @@ main(async () => {
};
});
function parseIndex(value) {
if (!/^[1-9]\d*$/.test(value)) {
throw new ScriptError('BAD_INDEX', `--index 需為正整數,收到的是 ${value}`);
}
return Number(value);
}
async function fetchIssue(login, repo, index, path) {
const response = await giteaRequest(login, 'GET', path);