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

Function parseUserDefinedArgs

packages/cli/src/internal/commandDescriptor.ts:570–602  ·  view source on GitHub ↗
(
        args: ReadonlyArray<string>
      )

Source from the content-addressed store, hash-verified

568 }
569 })
570 const parseUserDefinedArgs = (
571 args: ReadonlyArray<string>
572 ): Effect.Effect<
573 Directive.CommandDirective<unknown>,
574 ValidationError.ValidationError,
575 FileSystem.FileSystem | Path.Path | Terminal.Terminal
576 > =>
577 parseCommandLine(self, args).pipe(Effect.flatMap((commandOptionsAndArgs) => {
578 const [optionsAndArgs, forcedCommandArgs] = splitForcedArgs(commandOptionsAndArgs)
579 return InternalOptions.processCommandLine(self.options, optionsAndArgs, config).pipe(
580 Effect.flatMap(([error, commandArgs, optionsType]) =>
581 InternalArgs.validate(
582 self.args,
583 Arr.appendAll(commandArgs, forcedCommandArgs),
584 config
585 ).pipe(
586 Effect.catchAll((e) =>
587 Option.match(error, {
588 onNone: () => Effect.fail(e),
589 onSome: (err) => Effect.fail(err)
590 })
591 ),
592 Effect.map(([argsLeftover, argsType]) =>
593 InternalCommandDirective.userDefined(argsLeftover, {
594 name: self.name,
595 options: optionsType,
596 args: argsType
597 })
598 )
599 )
600 )
601 )
602 }))
603 const exhaustiveSearch = (
604 args: ReadonlyArray<string>
605 ): Effect.Effect<

Callers 1

parseInternalFunction · 0.85

Calls 6

splitForcedArgsFunction · 0.85
validateMethod · 0.80
parseCommandLineFunction · 0.70
pipeMethod · 0.65
failMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected