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

Function matchUnclustered

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

Source from the content-addressed store, hash-verified

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