(commandName: string, schema: CommandSchema)
| 929 | } |
| 930 | |
| 931 | function buildCommandUsage(commandName: string, schema: CommandSchema): string { |
| 932 | if (schema.usageOverride) return schema.usageOverride; |
| 933 | const positionals = (schema.positionalArgs ?? []).map(formatPositionalArg); |
| 934 | const flagLabels = (schema.allowedFlags ?? []).flatMap((key) => |
| 935 | flagDefinitionsForKey(key).map((definition) => definition.usageLabel ?? definition.names[0]), |
| 936 | ); |
| 937 | const optionalFlags = flagLabels.map((label) => `[${label}]`); |
| 938 | return [commandName, ...positionals, ...optionalFlags].join(' '); |
| 939 | } |
| 940 | |
| 941 | function flagDefinitionsForKey(key: FlagKey): FlagDefinition[] { |
| 942 | return getFlagDefinitions().filter((definition) => definition.key === key); |
no test coverage detected