50 lines
1.2 KiB
TypeScript
Executable File
50 lines
1.2 KiB
TypeScript
Executable File
#!/usr/bin/env runts -- --allow-all
|
|
|
|
import {
|
|
existsPath,
|
|
exit,
|
|
log,
|
|
makeDirectory,
|
|
writeStringToFile,
|
|
} from "https://script.hatter.ink/@70/deno-commons-mod.ts";
|
|
|
|
async function main(): Promise<void> {
|
|
const name = prompt("Cheat sheet name:");
|
|
const repo = prompt("Cheat sheet repo:");
|
|
const desc = prompt("Cheat sheet description:");
|
|
|
|
if (await existsPath(name)) {
|
|
log.error(`Path ${name} exists`);
|
|
}
|
|
const cheatsheetFile = `${name}/CHEATSHEET.md`;
|
|
if (await existsPath(cheatsheetFile)) {
|
|
log.error(`File ${cheatsheetFile} exists`);
|
|
}
|
|
await makeDirectory(name);
|
|
|
|
const md: string[] = [];
|
|
md.push(`# ${name}`);
|
|
md.push("");
|
|
md.push("## Meta");
|
|
md.push("");
|
|
md.push("```yaml");
|
|
md.push(`name: ${name}`);
|
|
if (repo) {
|
|
md.push(`repo: ${repo}`);
|
|
}
|
|
md.push(`description: ${desc}`);
|
|
md.push("```");
|
|
md.push("");
|
|
md.push("");
|
|
|
|
await writeStringToFile(cheatsheetFile, md.join("\n"));
|
|
}
|
|
|
|
main().catch((err) => {
|
|
log.error(err);
|
|
exit(1);
|
|
}).then(() => exit(0));
|
|
|
|
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T014242+08:00.MEUCIDaSrI8WyJa6nyc3Gd5D
|
|
// SP/P4BvB3pOKrU9FP7uB/QMAAiEAw/ZuIjxQnOVmSpiP/LRdcvPJlqeAkYaRjoPbMW9Pklg=
|