MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / printCallBrowseHelp

Function printCallBrowseHelp

apps/cli/src/main.ts:1662–1735  ·  view source on GitHub ↗
(input: {
  readonly prefixSegments: ReadonlyArray<string>;
  readonly children: ReadonlyArray<{
    readonly segment: string;
    readonly invokable: boolean;
    readonly hasChildren: boolean;
    readonly toolCount: number;
  }>;
  readonly totalChildren: number;
  readonly query: string | undefined;
  readonly limit: number | undefined;
  readonly exactTool:
    | {
        readonly id: string;
        readonly description?: string;
      }
    | undefined;
})

Source from the content-addressed store, hash-verified

1660};
1661
1662const printCallBrowseHelp = (input: {
1663 readonly prefixSegments: ReadonlyArray<string>;
1664 readonly children: ReadonlyArray<{
1665 readonly segment: string;
1666 readonly invokable: boolean;
1667 readonly hasChildren: boolean;
1668 readonly toolCount: number;
1669 }>;
1670 readonly totalChildren: number;
1671 readonly query: string | undefined;
1672 readonly limit: number | undefined;
1673 readonly exactTool:
1674 | {
1675 readonly id: string;
1676 readonly description?: string;
1677 }
1678 | undefined;
1679}) =>
1680 Effect.sync(() => {
1681 const prefixText = input.prefixSegments.join(" ");
1682 const commandPrefix = `${cliPrefix} call${prefixText.length > 0 ? ` ${prefixText}` : ""}`;
1683 const nextPlaceholder = input.prefixSegments.length === 0 ? "<namespace>" : "<subcommand>";
1684 const usageLines = [
1685 "Usage:",
1686 ` ${commandPrefix} ${nextPlaceholder} [<subcommand> ...] ['{"k":"v"}']`,
1687 ` ${commandPrefix} --help`,
1688 ` ${commandPrefix} --help [--match text] [--limit integer]`,
1689 ];
1690
1691 if (input.exactTool) {
1692 usageLines.push(` ${commandPrefix} ['{"k":"v"}']`);
1693 }
1694
1695 console.log(usageLines.join("\n"));
1696
1697 if (input.exactTool) {
1698 console.log(`\nCallable path: ${input.exactTool.id}`);
1699 if (input.exactTool.description) {
1700 console.log(sanitizeCliOutputText(input.exactTool.description));
1701 }
1702 }
1703
1704 if (input.children.length === 0) {
1705 console.log("\nNo subcommands at this level.");
1706 return;
1707 }
1708
1709 if (input.query && input.query.trim().length > 0) {
1710 console.log(`\nFiltered by: ${input.query}`);
1711 }
1712 if (input.children.length < input.totalChildren || input.limit) {
1713 const suffix = input.limit ? ` (limit ${input.limit})` : "";
1714 console.log(
1715 `Showing ${input.children.length} of ${input.totalChildren} subcommands${suffix}.`,
1716 );
1717 }
1718
1719 const rows = input.children.map((child) => {

Callers 1

runCallHelpFunction · 0.85

Calls 4

sanitizeCliOutputTextFunction · 0.90
syncMethod · 0.80
pushMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected