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

Function printCallBrowseHelp

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

1757};
1758
1759const printCallBrowseHelp = (input: {
1760 readonly prefixSegments: ReadonlyArray<string>;
1761 readonly children: ReadonlyArray<{
1762 readonly segment: string;
1763 readonly invokable: boolean;
1764 readonly hasChildren: boolean;
1765 readonly toolCount: number;
1766 }>;
1767 readonly totalChildren: number;
1768 readonly query: string | undefined;
1769 readonly limit: number | undefined;
1770 readonly exactTool:
1771 | {
1772 readonly id: string;
1773 readonly description?: string;
1774 }
1775 | undefined;
1776}) =>
1777 Effect.sync(() => {
1778 const prefixText = input.prefixSegments.join(" ");
1779 const commandPrefix = `${cliPrefix} call${prefixText.length > 0 ? ` ${prefixText}` : ""}`;
1780 const nextPlaceholder = input.prefixSegments.length === 0 ? "<namespace>" : "<subcommand>";
1781 const usageLines = [
1782 "Usage:",
1783 ` ${commandPrefix} ${nextPlaceholder} [<subcommand> ...] ['{"k":"v"}']`,
1784 ` ${commandPrefix} --help`,
1785 ` ${commandPrefix} --help [--match text] [--limit integer]`,
1786 ];
1787
1788 if (input.exactTool) {
1789 usageLines.push(` ${commandPrefix} ['{"k":"v"}']`);
1790 }
1791
1792 console.log(usageLines.join("\n"));
1793
1794 if (input.exactTool) {
1795 console.log(`\nCallable path: ${input.exactTool.id}`);
1796 if (input.exactTool.description) {
1797 console.log(sanitizeCliOutputText(input.exactTool.description));
1798 }
1799 }
1800
1801 if (input.children.length === 0) {
1802 console.log("\nNo subcommands at this level.");
1803 return;
1804 }
1805
1806 if (input.query && input.query.trim().length > 0) {
1807 console.log(`\nFiltered by: ${input.query}`);
1808 }
1809 if (input.children.length < input.totalChildren || input.limit) {
1810 const suffix = input.limit ? ` (limit ${input.limit})` : "";
1811 console.log(
1812 `Showing ${input.children.length} of ${input.totalChildren} subcommands${suffix}.`,
1813 );
1814 }
1815
1816 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