MCPcopy Index your code
hub / github.com/github/awesome-copilot / parseArgs

Function parseArgs

eng/create-plugin.mjs:21–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19}
20
21function parseArgs() {
22 const args = process.argv.slice(2);
23 const out = { name: undefined, keywords: undefined };
24
25 for (let i = 0; i < args.length; i++) {
26 const a = args[i];
27 if (a === "--name" || a === "-n") {
28 out.name = args[i + 1];
29 i++;
30 } else if (a.startsWith("--name=")) {
31 out.name = a.split("=")[1];
32 } else if (a === "--keywords" || a === "--tags" || a === "-t") {
33 out.keywords = args[i + 1];
34 i++;
35 } else if (a.startsWith("--keywords=") || a.startsWith("--tags=")) {
36 out.keywords = a.split("=")[1];
37 } else if (!a.startsWith("-") && !out.name) {
38 // first positional -> name
39 out.name = a;
40 } else if (!a.startsWith("-") && out.name && !out.keywords) {
41 // second positional -> keywords
42 out.keywords = a;
43 }
44 }
45
46 if (Array.isArray(out.keywords)) {
47 out.keywords = out.keywords.join(",");
48 }
49
50 return out;
51}
52
53async function createPlugin() {
54 try {

Callers 1

createPluginFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected