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

Function printCallBrowseHelp

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

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