MCPcopy
hub / github.com/callstack/agent-device / buildCommandUsageText

Function buildCommandUsageText

src/cli/parser/cli-help.ts:1054–1074  ·  view source on GitHub ↗
(commandName: string)

Source from the content-addressed store, hash-verified

1052}
1053
1054export function buildCommandUsageText(commandName: string): string | null {
1055 const topicHelp = buildHelpTopicUsageText(commandName);
1056 if (topicHelp) return topicHelp;
1057 const schema = getCommandSchema(commandName);
1058 if (!schema) return null;
1059 const usage = buildCommandUsage(commandName, schema);
1060 const commandFlags = listHelpFlags(new Set<FlagKey>(schema.allowedFlags ?? []));
1061 const sections: string[] = [];
1062 if (commandFlags.length > 0) {
1063 sections.push(renderFlagSection('Command flags:', commandFlags));
1064 }
1065 const flagsSections = sections.length > 0 ? `\n\n${sections.join('\n\n')}` : '';
1066
1067 return `agent-device ${usage}
1068
1069${schema.helpDescription}
1070
1071Usage:
1072 agent-device ${usage}${flagsSections}
1073`;
1074}
1075
1076function buildHelpTopicUsageText(topicName: string): string | null {
1077 const topic = HELP_TOPICS[topicName as keyof typeof HELP_TOPICS];

Callers 2

usageForCommandFunction · 0.90
runHelpFastPathFunction · 0.85

Calls 6

getCommandSchemaFunction · 0.90
buildHelpTopicUsageTextFunction · 0.85
buildCommandUsageFunction · 0.85
listHelpFlagsFunction · 0.85
renderFlagSectionFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected