MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / parseArgs

Function parseArgs

Support/SingleFileLibs/javascript/cli.js:26–45  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

24const { pathToFileURL } = require('node:url');
25
26function parseArgs(argv) {
27 const args = { repoRoot: '.', ref: 'HEAD', outDir: '_Build/_SingleFileLibraries', all: false, library: null };
28 for (let i = 2; i < argv.length; i++) {
29 const a = argv[i];
30 if (a === '--repo-root') args.repoRoot = argv[++i];
31 else if (a === '--ref') args.ref = argv[++i];
32 else if (a === '--out') args.outDir = argv[++i];
33 else if (a === '--all') args.all = true;
34 else if (a === '--library') args.library = argv[++i];
35 else if (a === '-h' || a === '--help') {
36 console.log('Usage: cli.js --repo-root <path> --ref <branch|tag|sha> (--all | --library <name>) --out <dir>');
37 process.exit(0);
38 }
39 }
40 if (!args.all && !args.library) {
41 console.error('Error: specify --all or --library <name>');
42 process.exit(1);
43 }
44 return args;
45}
46
47async function readText(path) { return await fsReadFile(path, 'utf8'); }
48async function writeText(path, content) { await fsWriteFile(path, content); }

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected