UNPKG

keygentoolshed

Version:

Key generation utilities for cryptographic operations. QUANTUM ENCRYPTION FOLDER UPDATE!!! See its folder for all <3

96 lines (88 loc) 2.88 kB
import fs from 'fs'; import yargs from 'yargs/yargs'; import { hideBin } from 'yargs/helpers'; const argv = yargs(hideBin(process.argv)) .usage('Usage: $0 --filePath [path] --amount [tiny|medium|giant]') .option('filePath', { alias: 'fp', describe: 'Specify the file path to add metadata', type: 'string', demandOption: true }) .option('amount', { alias: 'am', describe: 'Specify the amount of metadata (tiny, medium, giant)', type: 'string', choices: ['tiny', 'medium', 'giant'], demandOption: true }) .help() .argv; function addMetadata(filePath, amount) { let numberOfLines; switch (amount) { case 'tiny': numberOfLines = 3; break; case 'medium': numberOfLines = 5; break; case 'giant': numberOfLines = 10; break; default: console.error('Invalid amount specified.'); return; } const metadataLines = []; const currentDate = new Date().toISOString(); for (let i = 1; i <= numberOfLines; i++) { switch (i) { case 1: metadataLines.push(`Author: John Doe`); break; case 2: metadataLines.push(`Created on: ${currentDate}`); break; case 3: metadataLines.push(`Description: Metadata from addMetadata lol`); break; case 4: metadataLines.push(`Version: 1.0`); break; case 5: metadataLines.push(`Tags: example, sample, metadata`); break; case 6: metadataLines.push(`Last modified: ${currentDate}`); break; case 7: metadataLines.push(`Status: Draft`); break; case 8: metadataLines.push(`Reviewer: Jane Smith`); break; case 9: metadataLines.push(`Comments: Initial draft created.`); break; case 10: metadataLines.push(`License: MIT`); break; default: metadataLines.push(`Additional metadata line ${i - 10}: Example content`); break; } } fs.appendFile(filePath, metadataLines.join('\n') + '\n', (err) => { if (err) { console.error(`Error writing to file: ${err.message}`); } else { console.log(`Successfully added ${numberOfLines} metadata lines to file: ${filePath}`); } }); } function main() { const { filePath, amount } = argv; addMetadata(filePath, amount); } main();