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

Function printCallBrowseHelp

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

1714};
1715
1716const printCallBrowseHelp = (input: {
1717 readonly prefixSegments: ReadonlyArray<string>;
1718 readonly children: ReadonlyArray<{
1719 readonly segment: string;
1720 readonly invokable: boolean;
1721 readonly hasChildren: boolean;
1722 readonly toolCount: number;
1723 }>;
1724 readonly totalChildren: number;
1725 readonly query: string | undefined;
1726 readonly limit: number | undefined;
1727 readonly exactTool:
1728 | {
1729 readonly id: string;
1730 readonly description?: string;
1731 }
1732 | undefined;
1733}) =>
1734 Effect.sync(() => {
1735 const prefixText = input.prefixSegments.join(" ");
1736 const commandPrefix = `${cliPrefix} call${prefixText.length > 0 ? ` ${prefixText}` : ""}`;
1737 const nextPlaceholder = input.prefixSegments.length === 0 ? "<namespace>" : "<subcommand>";
1738 const usageLines = [
1739 "Usage:",
1740 ` ${commandPrefix} ${nextPlaceholder} [<subcommand> ...] ['{"k":"v"}']`,
1741 ` ${commandPrefix} --help`,
1742 ` ${commandPrefix} --help [--match text] [--limit integer]`,
1743 ];
1744
1745 if (input.exactTool) {
1746 usageLines.push(` ${commandPrefix} ['{"k":"v"}']`);
1747 }
1748
1749 console.log(usageLines.join("\n"));
1750
1751 if (input.exactTool) {
1752 console.log(`\nCallable path: ${input.exactTool.id}`);
1753 if (input.exactTool.description) {
1754 console.log(sanitizeCliOutputText(input.exactTool.description));
1755 }
1756 }
1757
1758 if (input.children.length === 0) {
1759 console.log("\nNo subcommands at this level.");
1760 return;
1761 }
1762
1763 if (input.query && input.query.trim().length > 0) {
1764 console.log(`\nFiltered by: ${input.query}`);
1765 }
1766 if (input.children.length < input.totalChildren || input.limit) {
1767 const suffix = input.limit ? ` (limit ${input.limit})` : "";
1768 console.log(
1769 `Showing ${input.children.length} of ${input.totalChildren} subcommands${suffix}.`,
1770 );
1771 }
1772
1773 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