| 19 | } |
| 20 | |
| 21 | function 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 | |
| 53 | async function createPlugin() { |
| 54 | try { |