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

Function resolveFlag

packages/effect/src/unstable/cli/internal/parser.ts:348–380  ·  view source on GitHub ↗
(
  token: FlagToken,
  registry: FlagRegistry
)

Source from the content-addressed store, hash-verified

346const getFlagName = (t: FlagToken): string => t._tag === "LongOption" ? t.name : t.flag
347
348const resolveFlag = (
349 token: FlagToken,
350 registry: FlagRegistry
351): ResolvedFlag | undefined => {
352 const tokenName = getFlagName(token)
353 const direct = registry.index.get(tokenName)
354 if (direct && direct.name === tokenName) {
355 return {
356 param: direct,
357 negated: false
358 }
359 }
360
361 if (token._tag === "LongOption" && token.name.startsWith("no-")) {
362 const canonicalName = token.name.slice(3)
363 const param = registry.index.get(canonicalName)
364 if (param && param.name === canonicalName && Primitive.isBoolean(param.primitiveType)) {
365 return {
366 param,
367 negated: true
368 }
369 }
370 }
371
372 if (direct) {
373 return {
374 param: direct,
375 negated: false
376 }
377 }
378
379 return undefined
380}
381
382const invalidNegatedFlagValue = (
383 token: FlagToken,

Callers 4

consumeKnownFlagsFunction · 0.85
resolveFromRegistriesFunction · 0.85
consumeLevelFunction · 0.85
processFlagFunction · 0.85

Calls 2

getFlagNameFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected