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

Function printCallBrowseHelp

apps/cli/src/main.ts:1685–1758  ·  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

1683};
1684
1685const printCallBrowseHelp = (input: {
1686 readonly prefixSegments: ReadonlyArray<string>;
1687 readonly children: ReadonlyArray<{
1688 readonly segment: string;
1689 readonly invokable: boolean;
1690 readonly hasChildren: boolean;
1691 readonly toolCount: number;
1692 }>;
1693 readonly totalChildren: number;
1694 readonly query: string | undefined;
1695 readonly limit: number | undefined;
1696 readonly exactTool:
1697 | {
1698 readonly id: string;
1699 readonly description?: string;
1700 }
1701 | undefined;
1702}) =>
1703 Effect.sync(() => {
1704 const prefixText = input.prefixSegments.join(" ");
1705 const commandPrefix = `${cliPrefix} call${prefixText.length > 0 ? ` ${prefixText}` : ""}`;
1706 const nextPlaceholder = input.prefixSegments.length === 0 ? "<namespace>" : "<subcommand>";
1707 const usageLines = [
1708 "Usage:",
1709 ` ${commandPrefix} ${nextPlaceholder} [<subcommand> ...] ['{"k":"v"}']`,
1710 ` ${commandPrefix} --help`,
1711 ` ${commandPrefix} --help [--match text] [--limit integer]`,
1712 ];
1713
1714 if (input.exactTool) {
1715 usageLines.push(` ${commandPrefix} ['{"k":"v"}']`);
1716 }
1717
1718 console.log(usageLines.join("\n"));
1719
1720 if (input.exactTool) {
1721 console.log(`\nCallable path: ${input.exactTool.id}`);
1722 if (input.exactTool.description) {
1723 console.log(sanitizeCliOutputText(input.exactTool.description));
1724 }
1725 }
1726
1727 if (input.children.length === 0) {
1728 console.log("\nNo subcommands at this level.");
1729 return;
1730 }
1731
1732 if (input.query && input.query.trim().length > 0) {
1733 console.log(`\nFiltered by: ${input.query}`);
1734 }
1735 if (input.children.length < input.totalChildren || input.limit) {
1736 const suffix = input.limit ? ` (limit ${input.limit})` : "";
1737 console.log(
1738 `Showing ${input.children.length} of ${input.totalChildren} subcommands${suffix}.`,
1739 );
1740 }
1741
1742 const rows = input.children.map((child) => {

Callers 1

runCallHelpFunction · 0.85

Calls 4

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

Tested by

no test coverage detected