23 lines
1.3 KiB
JavaScript
23 lines
1.3 KiB
JavaScript
function getCurlCommand({ full = true } = {}) {
|
|
const args = [];
|
|
const selectedFiles = files.length ? files : [{ displayName: "build.zip" }];
|
|
const previewLimit = full ? selectedFiles.length : 4;
|
|
selectedFiles.slice(0, previewLimit).forEach((item) => args.push(` -F ${shellQuote(`files=@${item.displayName}`)}`));
|
|
const hiddenFileCount = !full && selectedFiles.length > previewLimit ? selectedFiles.length - previewLimit : 0;
|
|
args.push(` -F ${shellQuote(`retention=${el.expiry?.value || defaultRetention}`)}`);
|
|
if (el.password?.value) args.push(` -F ${shellQuote("password=YOUR_PASSWORD")}`);
|
|
if (el.allowZip && !el.allowZip.checked) args.push(` -F ${shellQuote("allow_zip=false")}`);
|
|
|
|
const commandLines = ["curl"];
|
|
if (el.apiKeyMode?.checked) commandLines.push(` -H ${shellQuote("Authorization: Bearer YOUR_API_KEY")}`);
|
|
commandLines.push(...args, ` ${window.location.origin}/upload`);
|
|
const command = commandLines.join(" \\\n");
|
|
return hiddenFileCount ? `${command}\n# and ${hiddenFileCount} other files included when copying` : command;
|
|
}
|
|
|
|
function updateTerminal() {
|
|
if (!el.terminal) return;
|
|
const command = getCurlCommand({ full: false });
|
|
el.terminal.innerHTML = `<span class="terminal-muted">warpbox@cli</span>:~$ ${htmlEscape(command)}`;
|
|
}
|