Accept Google Sheets URL in wizard and extract spreadsheet ID
build-windows-exe / build (push) Successful in 26s

This commit is contained in:
2026-07-18 11:58:23 +01:00
parent 26702cec4f
commit 5e6b5d37d1
+31 -1
View File
@@ -78,6 +78,33 @@ async function askOptionalPositiveInteger(ask, question, defaultValue) {
}
}
function extractSpreadsheetId(input) {
const value = (input || '').trim();
if (!value) {
return '';
}
const urlMatch = value.match(/\/spreadsheets\/d\/([a-zA-Z0-9-_]+)/i);
if (urlMatch && urlMatch[1]) {
return urlMatch[1];
}
return value;
}
async function askSpreadsheetIdOrUrl(ask, question) {
while (true) {
const answer = await ask(question);
const documentId = extractSpreadsheetId(answer);
if (documentId) {
return documentId;
}
console.log('Please enter a Google Sheets URL or spreadsheet ID.');
}
}
async function pauseForEnter(ask) {
await ask('Press Enter to close this window...');
}
@@ -176,7 +203,10 @@ async function runOnboarding() {
const documentCount = await askPositiveInteger(ask, 'How many documents do you want to pull from? ');
for (let documentIndex = 0; documentIndex < documentCount; documentIndex += 1) {
const documentId = await askNonEmpty(ask, `Enter document ID ${documentIndex + 1}: `);
const documentId = await askSpreadsheetIdOrUrl(
ask,
`Enter Google Sheets URL or document ID ${documentIndex + 1}: `
);
let documentTitle = documentId;
try {