MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / parseArgs

Function parseArgs

scripts/experimental/swiftui-preview.mjs:86–125  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

84}
85
86function parseArgs(argv) {
87 const args = {};
88 for (let index = 0; index < argv.length; index += 1) {
89 const arg = argv[index];
90 if (arg === "--help" || arg === "-h") {
91 args.help = true;
92 } else if (arg === "--watch" || arg === "-w") {
93 args.watch = true;
94 } else if (arg === "--rebuild-host") {
95 args.rebuildHost = true;
96 } else if (arg === "--skip-xcode-build") {
97 args.skipXcodeBuild = true;
98 } else if (arg === "--skip-codesign") {
99 args.skipCodesign = true;
100 } else if (arg === "--profile") {
101 args.profile = true;
102 } else if (arg === "--split-compile") {
103 args.splitCompile = true;
104 } else if (arg.startsWith("--")) {
105 const key = arg
106 .slice(2)
107 .replace(/-([a-z])/g, (_, char) => char.toUpperCase());
108 const next = argv[index + 1];
109 if (!next || next.startsWith("--")) {
110 throw new Error(`Missing value for ${arg}.`);
111 }
112 index += 1;
113 if (key === "extraSwift" || key === "swiftcArg") {
114 args[key] = [...arrayArg(args[key]), next];
115 } else {
116 args[key] = next;
117 }
118 } else if (!args.file) {
119 args.file = arg;
120 } else {
121 args.extraSwift = [...arrayArg(args.extraSwift), arg];
122 }
123 }
124 return args;
125}
126
127function printUsage() {
128 console.log(`Usage:

Callers 1

mainFunction · 0.70

Calls 2

arrayArgFunction · 0.85
replaceMethod · 0.65

Tested by

no test coverage detected