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