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

Function getHelpForCommandPath

packages/effect/src/unstable/cli/internal/help.ts:152–183  ·  view source on GitHub ↗
(
  command: Command<Name, Input, ContextInput, E, R>,
  commandPath: ReadonlyArray<string>,
  builtIns: ReadonlyArray<GlobalFlag.GlobalFlag<any>>
)

Source from the content-addressed store, hash-verified

150 * Reads active global flags for the path and includes them in the help doc.
151 */
152export const getHelpForCommandPath = <Name extends string, Input, E, R, ContextInput>(
153 command: Command<Name, Input, ContextInput, E, R>,
154 commandPath: ReadonlyArray<string>,
155 builtIns: ReadonlyArray<GlobalFlag.GlobalFlag<any>>
156): Effect.Effect<HelpDoc, never, never> =>
157 Effect.gen(function*() {
158 const commands = getCommandsForCommandPath(command, commandPath)
159 const currentCommand = commands.length > 0 ? commands[commands.length - 1] : command
160
161 const baseDoc = toImpl(currentCommand).buildHelpDoc(commandPath)
162
163 const sharedFlags = getSharedFlagsForCommandPath(commands, baseDoc.flags)
164
165 const flags = getGlobalFlagsForCommandPath(command, commandPath, builtIns)
166 const globalFlagDocs: Array<FlagDoc> = []
167 for (const flag of flags) {
168 const singles = Param.extractSingleParams(flag.flag)
169 const metadata = Param.getParamMetadata(flag.flag)
170 for (const single of singles) {
171 // Same rule as command-local flags: hidden globals are still parsed
172 // and still trigger their handlers, they just don't appear under
173 // "GLOBAL FLAGS" in --help.
174 if (single.hidden) continue
175 globalFlagDocs.push({
176 ...toFlagDoc(single, metadata),
177 required: false
178 })
179 }
180 }
181
182 return { ...baseDoc, flags: [...sharedFlags, ...baseDoc.flags], globalFlags: globalFlagDocs }
183 })

Callers 1

showHelpFunction · 0.90

Calls 6

toImplFunction · 0.90
toFlagDocFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected