(commandName: string)
| 1052 | } |
| 1053 | |
| 1054 | export 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 | |
| 1071 | Usage: |
| 1072 | agent-device ${usage}${flagsSections} |
| 1073 | `; |
| 1074 | } |
| 1075 | |
| 1076 | function buildHelpTopicUsageText(topicName: string): string | null { |
| 1077 | const topic = HELP_TOPICS[topicName as keyof typeof HELP_TOPICS]; |
no test coverage detected