MCPcopy Create free account
hub / github.com/chhoumann/quickadd / parseArgs

Function parseArgs

scripts/start-obsidian-e2e-instance.mjs:45–94  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

43}
44
45export function parseArgs(argv) {
46 const options = {
47 force: false,
48 json: false,
49 launch: true,
50 printEnv: false,
51 };
52
53 for (let index = 0; index < argv.length; index += 1) {
54 const arg = argv[index];
55 switch (arg) {
56 case "--":
57 break;
58 case "--force":
59 options.force = true;
60 break;
61 case "--json":
62 options.json = true;
63 break;
64 case "--no-launch":
65 options.launch = false;
66 break;
67 case "--print-env":
68 options.printEnv = true;
69 break;
70 case "--help":
71 options.help = true;
72 break;
73 case "--vault":
74 case "--root":
75 case "--worktree":
76 case "--data":
77 case "--profile-root":
78 case "--obsidian-app":
79 case "--obsidian-bin": {
80 const value = argv[index + 1];
81 if (!value || value.startsWith("--")) {
82 throw new Error(`${arg} requires a value.`);
83 }
84 options[toOptionKey(arg)] = value;
85 index += 1;
86 break;
87 }
88 default:
89 throw new Error(`Unknown option: ${arg}`);
90 }
91 }
92
93 return options;
94}
95
96function toOptionKey(arg) {
97 if (arg === "--profile-root") return "profileRoot";

Callers 1

mainFunction · 0.70

Calls 1

toOptionKeyFunction · 0.70

Tested by

no test coverage detected