MCPcopy Create free account
hub / github.com/Maksandre/w3wallets / parseArgs

Function parseArgs

packages/w3wallets/src/scripts/cache.ts:9–51  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

7}
8
9function parseArgs(args: string[]): CacheOptions {
10 const options: CacheOptions = {
11 force: false,
12 headed: false,
13 directory: "./wallets-cache/",
14 };
15
16 for (const arg of args) {
17 if (arg === "-f" || arg === "--force") {
18 options.force = true;
19 } else if (arg === "--headed") {
20 options.headed = true;
21 } else if (arg === "-h" || arg === "--help") {
22 console.log(`
23w3wallets cache - Build wallet caches from setup files
24
25USAGE:
26 npx w3wallets cache [OPTIONS] [directory]
27
28ARGUMENTS:
29 directory Directory containing *.cache.{ts,js} files (default: ./wallets-cache/)
30
31OPTIONS:
32 -f, --force Force rebuild even if cache exists
33 --headed Run browser in headed mode
34 -h, --help Show this help message
35
36EXAMPLES:
37 npx w3wallets cache # Build caches from ./wallets-cache/
38 npx w3wallets cache ./tests/setups/ # Custom directory
39 npx w3wallets cache --force # Force rebuild
40`);
41 process.exit(0);
42 } else if (!arg.startsWith("-")) {
43 options.directory = arg;
44 } else {
45 console.error(`Error: Unknown option "${arg}"`);
46 process.exit(1);
47 }
48 }
49
50 return options;
51}
52
53const options = parseArgs(process.argv.slice(2));
54

Callers 1

cache.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected