MCPcopy Index your code
hub / github.com/callstack/agent-device / buildCommandUsage

Function buildCommandUsage

src/cli/parser/cli-help.ts:931–939  ·  view source on GitHub ↗
(commandName: string, schema: CommandSchema)

Source from the content-addressed store, hash-verified

929}
930
931function 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
941function flagDefinitionsForKey(key: FlagKey): FlagDefinition[] {
942 return getFlagDefinitions().filter((definition) => definition.key === key);

Callers 1

buildCommandUsageTextFunction · 0.85

Calls 1

flagDefinitionsForKeyFunction · 0.85

Tested by

no test coverage detected