MCPcopy Create free account
hub / github.com/blockmatic/basilic / buildOpts

Function buildOpts

packages/cli/src/cli.ts:55–74  ·  view source on GitHub ↗
(
  meta: (typeof operationMeta)[keyof typeof operationMeta],
  cmdOpts: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

53}
54
55function buildOpts(
56 meta: (typeof operationMeta)[keyof typeof operationMeta],
57 cmdOpts: Record<string, unknown>,
58): Record<string, string | undefined> {
59 const opts: Record<string, string | undefined> = {}
60 const rawBody = cmdOpts.body as string | undefined
61 if (rawBody)
62 try {
63 const parsed = JSON.parse(rawBody) as Record<string, unknown>
64 for (const [k, v] of Object.entries(parsed)) if (v !== undefined) opts[k] = String(v)
65 return opts
66 } catch {
67 console.error('Invalid --body JSON')
68 process.exit(1)
69 }
70
71 for (const p of meta.pathParams) opts[p.name] = String(cmdOpts[p.name] ?? '')
72 for (const p of meta.bodyParams) opts[p.name] = String(cmdOpts[p.name] ?? '')
73 return opts
74}
75
76function toKebab(str: string): string {
77 return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()

Callers 1

registerApiCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected