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

Function printCallBrowseHelp

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

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