MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeParser

Function makeParser

packages/effect/src/unstable/cli/internal/command.ts:271–284  ·  view source on GitHub ↗
(
  cfg: ConfigInternal,
  options?: {
    readonly allowLeftovers?: boolean | undefined
  } | undefined
)

Source from the content-addressed store, hash-verified

269 * full throwaway command.
270 */
271export const makeParser = (
272 cfg: ConfigInternal,
273 options?: {
274 readonly allowLeftovers?: boolean | undefined
275 } | undefined
276) =>
277 Effect.fnUntraced(function*(input: ParsedTokens) {
278 const parsedArgs: Param.ParsedArgs = { flags: input.flags, arguments: input.arguments }
279 const [remainingArguments, values] = yield* parseParams(parsedArgs, cfg.orderedParams)
280 if (options?.allowLeftovers !== true && remainingArguments.length > 0) {
281 return yield* new CliError.UnexpectedArgument({ arguments: remainingArguments })
282 }
283 return reconstructTree(cfg.tree, values)
284 })
285
286/**
287 * Parses param values from parsed command arguments into their typed

Callers 2

Command.tsFile · 0.90
makeCommandFunction · 0.70

Calls 1

reconstructTreeFunction · 0.90

Tested by

no test coverage detected