MCPcopy Create free account
hub / github.com/BCsabaEngine/svelteesp32 / parseArguments

Function parseArguments

src/commandLine.ts:476–731  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

474}
475
476export function parseArguments(): ICopyFilesArguments {
477 const arguments_ = process.argv.slice(2);
478
479 // STEP 1: Check for --config flag first
480 let customConfigPath: string | undefined;
481 for (let index = 0; index < arguments_.length; index++) {
482 const argument = arguments_[index];
483 if (!argument) continue;
484
485 if (argument === '--config' && arguments_[index + 1] !== undefined) {
486 customConfigPath = arguments_[index + 1];
487 break;
488 }
489 if (argument.startsWith('--config=')) {
490 customConfigPath = argument.slice('--config='.length);
491 break;
492 }
493 }
494
495 // STEP 2: Find and load RC file
496 const rcPath = findRcFile(customConfigPath);
497
498 if (rcPath) {
499 console.log(cyanLog(`[SvelteESP32] Using config from: ${rcPath}`));
500 if (!customConfigPath && path.dirname(rcPath) === process.cwd())
501 console.warn(
502 yellowLog(`Warning: Loading config from current directory — verify this file is trusted before proceeding.`)
503 );
504 }
505
506 const rcConfig = rcPath ? loadRcFile(rcPath) : {};
507
508 // STEP 3: Initialize with defaults
509 const result: Partial<ICopyFilesArguments> = {
510 engine: 'psychic',
511 outputfile: 'svelteesp32.h',
512 etag: 'never',
513 gzip: 'always',
514 created: false,
515 version: '',
516 espmethod: 'initSvelteStaticFiles',
517 define: 'SVELTEESP32',
518 cachetime: 0,
519 exclude: [],
520 basePath: '',
521 configSource: 'cli'
522 };
523
524 // STEP 4: Merge RC file values
525 if (rcConfig.engine) result.engine = rcConfig.engine;
526 if (rcConfig.sourcepath) result.sourcepath = rcConfig.sourcepath;
527 if (rcConfig.outputfile) result.outputfile = rcConfig.outputfile;
528 if (rcConfig.etag) result.etag = rcConfig.etag;
529 if (rcConfig.gzip) result.gzip = rcConfig.gzip;
530 if (rcConfig.cachetime !== undefined) result.cachetime = rcConfig.cachetime;
531 if (rcConfig.cachetimehtml !== undefined) result.cachetimeHtml = rcConfig.cachetimehtml;
532 if (rcConfig.cachetimeassets !== undefined) result.cachetimeAssets = rcConfig.cachetimeassets;
533 if (rcConfig.created !== undefined) result.created = rcConfig.created === true || rcConfig.created === 'true';

Callers 2

mainFunction · 0.90

Calls 8

cyanLogFunction · 0.90
yellowLogFunction · 0.90
findRcFileFunction · 0.85
loadRcFileFunction · 0.85
validateBasePathFunction · 0.85
showHelpFunction · 0.85
applyFlagFunction · 0.85
validateEngineFunction · 0.85

Tested by

no test coverage detected