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

Function printCallBrowseHelp

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

1736};
1737
1738const printCallBrowseHelp = (input: {
1739 readonly prefixSegments: ReadonlyArray<string>;
1740 readonly children: ReadonlyArray<{
1741 readonly segment: string;
1742 readonly invokable: boolean;
1743 readonly hasChildren: boolean;
1744 readonly toolCount: number;
1745 }>;
1746 readonly totalChildren: number;
1747 readonly query: string | undefined;
1748 readonly limit: number | undefined;
1749 readonly exactTool:
1750 | {
1751 readonly id: string;
1752 readonly description?: string;
1753 }
1754 | undefined;
1755}) =>
1756 Effect.sync(() => {
1757 const prefixText = input.prefixSegments.join(" ");
1758 const commandPrefix = `${cliPrefix} call${prefixText.length > 0 ? ` ${prefixText}` : ""}`;
1759 const nextPlaceholder = input.prefixSegments.length === 0 ? "<namespace>" : "<subcommand>";
1760 const usageLines = [
1761 "Usage:",
1762 ` ${commandPrefix} ${nextPlaceholder} [<subcommand> ...] ['{"k":"v"}']`,
1763 ` ${commandPrefix} --help`,
1764 ` ${commandPrefix} --help [--match text] [--limit integer]`,
1765 ];
1766
1767 if (input.exactTool) {
1768 usageLines.push(` ${commandPrefix} ['{"k":"v"}']`);
1769 }
1770
1771 console.log(usageLines.join("\n"));
1772
1773 if (input.exactTool) {
1774 console.log(`\nCallable path: ${input.exactTool.id}`);
1775 if (input.exactTool.description) {
1776 console.log(sanitizeCliOutputText(input.exactTool.description));
1777 }
1778 }
1779
1780 if (input.children.length === 0) {
1781 console.log("\nNo subcommands at this level.");
1782 return;
1783 }
1784
1785 if (input.query && input.query.trim().length > 0) {
1786 console.log(`\nFiltered by: ${input.query}`);
1787 }
1788 if (input.children.length < input.totalChildren || input.limit) {
1789 const suffix = input.limit ? ` (limit ${input.limit})` : "";
1790 console.log(
1791 `Showing ${input.children.length} of ${input.totalChildren} subcommands${suffix}.`,
1792 );
1793 }
1794
1795 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