MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / parseArgs

Function parseArgs

apps/api/scripts/codegen/new-resource.ts:27–46  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

25);
26
27const parseArgs = (argv: string[]): string => {
28 const arg = argv.slice(2).find((value) => value !== "--");
29 const name = arg?.trim();
30
31 if (name === undefined || name === "") {
32 console.error(
33 "Usage: bun run new:resource -- <PascalName>\nExample: bun run new:resource -- Posts"
34 );
35 process.exit(1);
36 }
37
38 if (!/^[A-Z][\dA-Za-z]*$/.test(name)) {
39 console.error(
40 `Invalid PascalCase name "${name}". Use letters/digits only, starting with uppercase (e.g. Posts).`
41 );
42 process.exit(1);
43 }
44
45 return name;
46};
47
48const toFilePrefix = (pascal: string): string =>
49 pascal.charAt(0).toLowerCase() + pascal.slice(1);

Callers 1

new-resource.tsFile · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected