MCPcopy Create free account
hub / github.com/langgenius/dify / renderCommandRows

Function renderCommandRows

cli/src/framework/help.ts:169–189  ·  view source on GitHub ↗
(commands: Array<{ command: CommandConstructor, path: string[] }>)

Source from the content-addressed store, hash-verified

167// derive from the same full-depth `collectCommands` walk and the canonical
168// space-joined command path.
169export function renderCommandRows(commands: Array<{ command: CommandConstructor, path: string[] }>): string {
170 const rows = commands.map(({ command, path }) => ({
171 label: path.join(' '),
172 desc: command.description ?? '',
173 group: path[0] ?? '',
174 }))
175
176 const width = rows.reduce((max, r) => Math.max(max, r.label.length), 0) + 2
177 const lines: string[] = []
178 let prevGroup: string | undefined
179
180 for (const r of rows) {
181 if (prevGroup !== undefined && r.group !== prevGroup)
182 lines.push('')
183
184 prevGroup = r.group
185 lines.push(r.desc ? ` ${r.label.padEnd(width)}${r.desc}` : ` ${r.label}`)
186 }
187
188 return lines.join('\n')
189}
190
191// Renders a command list (a namespace subtree for `<group> --help`) in the
192// requested format: structured formats serialize per-command descriptors — the

Callers 2

formatCommandListFunction · 0.85
formatTopLevelHelpTextFunction · 0.85

Calls 4

mapMethod · 0.45
joinMethod · 0.45
reduceMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected