MCPcopy Create free account
hub / github.com/decaporg/decap-cms / commandHelp

Function commandHelp

packages/decap/src/commands.ts:120–147  ·  view source on GitHub ↗
(op: Operation)

Source from the content-addressed store, hash-verified

118}
119
120export function commandHelp(op: Operation): string {
121 const required = new Set(op.input.required ?? []);
122 const lines = [`decap ${op.cli!.command.join(' ')}`, '', op.summary, ''];
123 const fields = Object.entries(op.input.properties);
124 if (fields.length > 0) {
125 lines.push('Flags:');
126 const width = Math.max(...fields.map(([field]) => flagName(field).length)) + 2;
127 for (const [field, prop] of fields) {
128 const choices =
129 prop.type === 'string' && prop.enum
130 ? ` (${prop.enum.join(', ')})`
131 : prop.type === 'object'
132 ? ' (JSON)'
133 : '';
134 lines.push(
135 ` --${flagName(field).padEnd(width)}${required.has(field) ? 'required. ' : ''}${
136 prop.description ?? ''
137 }${choices}`,
138 );
139 }
140 lines.push('');
141 }
142 lines.push(
143 `Needs ${op.scope === 'admin' ? 'admin scope (decap login --admin)' : 'a signed-in token'}.`,
144 );
145 lines.push('Add --json for machine-readable output.');
146 return lines.join('\n');
147}
148
149/** One line per command, for the main help. */
150export function commandList(): string {

Callers 2

mainFunction · 0.85
commands.spec.tsFile · 0.85

Calls 3

flagNameFunction · 0.90
mapMethod · 0.80
hasMethod · 0.80

Tested by

no test coverage detected