MCPcopy Index your code
hub / github.com/Effect-TS/effect / matchUnclustered

Function matchUnclustered

packages/cli/src/internal/options.ts:1981–2017  ·  view source on GitHub ↗
(
  input: ReadonlyArray<string>,
  tail: ReadonlyArray<string>,
  options: ReadonlyArray<ParseableInstruction>,
  config: CliConfig.CliConfig
)

Source from the content-addressed store, hash-verified

1979}
1980
1981const matchUnclustered = (
1982 input: ReadonlyArray<string>,
1983 tail: ReadonlyArray<string>,
1984 options: ReadonlyArray<ParseableInstruction>,
1985 config: CliConfig.CliConfig
1986): Effect.Effect<
1987 [
1988 ReadonlyArray<string>,
1989 ReadonlyArray<ParseableInstruction>,
1990 HashMap.HashMap<string, ReadonlyArray<string>>
1991 ],
1992 ValidationError.ValidationError
1993> => {
1994 if (Arr.isNonEmptyReadonlyArray(input)) {
1995 const flag = Arr.headNonEmpty(input)
1996 const otherFlags = Arr.tailNonEmpty(input)
1997 return findOptions(Arr.of(flag), options, config).pipe(
1998 Effect.flatMap(([_, opts1, map1]) => {
1999 if (HashMap.isEmpty(map1)) {
2000 return Effect.fail(
2001 InternalValidationError.unclusteredFlag(
2002 InternalHelpDoc.empty,
2003 Arr.empty(),
2004 tail
2005 )
2006 )
2007 }
2008 return matchUnclustered(otherFlags, tail, opts1, config).pipe(
2009 Effect.map((
2010 [_, opts2, map2]
2011 ) => [tail, opts2, merge(map1, Arr.fromIterable(map2))])
2012 )
2013 })
2014 )
2015 }
2016 return Effect.succeed([tail, options, HashMap.empty()])
2017}
2018
2019/**
2020 * Sums the list associated with the same key.

Callers 1

findOptionsFunction · 0.85

Calls 7

findOptionsFunction · 0.85
mergeFunction · 0.70
pipeMethod · 0.65
ofMethod · 0.65
isEmptyMethod · 0.65
failMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected