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

Function formatHelpText

cli/src/framework/help.ts:103–148  ·  view source on GitHub ↗
(ctor: CommandConstructor, path: string)

Source from the content-addressed store, hash-verified

101}
102
103function formatHelpText(ctor: CommandConstructor, path: string): string {
104 const lines: string[] = []
105
106 if (ctor.description)
107 lines.push(ctor.description, '')
108
109 lines.push('USAGE', ` $ ${BIN} ${path}${ctor.args && Object.keys(ctor.args).length > 0 ? ' [ARGS]' : ''}${ctor.flags && Object.keys(ctor.flags).length > 0 ? ' [FLAGS]' : ''}`, '')
110
111 if (ctor.args && Object.keys(ctor.args).length > 0) {
112 lines.push('ARGUMENTS')
113
114 for (const [name, def] of Object.entries(ctor.args)) {
115 const required = def.required ? ' (required)' : ''
116 lines.push(` ${name}${required} ${def.description}`)
117 }
118
119 lines.push('')
120 }
121
122 if (ctor.flags && Object.keys(ctor.flags).length > 0) {
123 lines.push('FLAGS')
124
125 for (const [name, def] of Object.entries(ctor.flags)) {
126 lines.push(` ${flagLabel(name, def)} ${def.description}${flagDefault(def)}`)
127 }
128
129 lines.push('')
130 }
131
132 if (ctor.examples && ctor.examples.length > 0) {
133 lines.push('EXAMPLES')
134
135 for (const ex of renderExamples(ctor)) {
136 lines.push(` $ ${ex}`)
137 }
138
139 lines.push('')
140 }
141
142 const guide = agentGuideOf(ctor)
143
144 if (guide.length > 0)
145 lines.push(guide)
146
147 return lines.join('\n')
148}
149
150export function formatHelp(ctor: CommandConstructor, path: string, format = ''): string {
151 if (isStructured(format))

Callers 1

formatHelpFunction · 0.85

Calls 8

flagLabelFunction · 0.85
flagDefaultFunction · 0.85
renderExamplesFunction · 0.85
agentGuideOfFunction · 0.85
pushMethod · 0.45
keysMethod · 0.45
entriesMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected