UNPKG

ws-dottie

Version:

Your friendly TypeScript companion for Washington State transportation APIs - WSDOT and WSF data with smart caching and React Query integration

113 lines 4.69 kB
/** * @fileoverview UI and Output Utilities for WS-Dottie CLI * * This module provides user interface and output utilities for WS-Dottie * command-line tools. It includes error handling, output formatting, * console control, and help text generation functionality. * * ## Key Features * * - **Error Handling**: Comprehensive error handling with helpful context and tips * - **Output Formatting**: Pretty-printing, truncation, and formatting options * - **Console Control**: Suppression and restoration of console output * - **Help Generation**: Dynamic help text with examples and function listings * - **User Feedback**: Colored output and informative messages */ import type { CliOptions } from "./types"; /** * Handles errors with consistent formatting and helpful context * * This function provides comprehensive error handling for CLI tools, including * error message extraction, context-specific tips, and appropriate exit codes. * It handles both ApiError instances and generic errors with different * formatting and context information. * * @param error - The error to handle (can be any type) * @param functionName - Name of the function that caused the error * @throws Never returns, always exits process with code 1 */ export declare const handleError: (error: unknown, functionName: string) => never; /** * Displays collision error when multiple endpoints have the same name * * This function provides a helpful error message when a requested function * name matches multiple endpoints, showing the user how to use namespace * syntax to disambiguate. * * @param endpointName - The endpoint name that has collisions * @param matchingEndpoints - Array of endpoints that match the name */ export declare const displayCollisionError: (endpointName: string, matchingEndpoints: Array<{ api: { name: string; }; functionName: string; urlTemplate: string; }>) => void; /** * Displays function not found error with list of available functions * * This function provides a helpful error message when a requested function * is not found, including a list of all available functions to help users * find the correct function name. * * @param functionName - The function name that was not found */ export declare const displayFunctionNotFound: (functionName: string) => void; /** * Outputs result with formatting based on CLI options * * This function formats and outputs the API response data according to * the specified CLI options, including pretty-printing and truncation. * Now uses colorized output by default in all cases. * * @param result - The result data to output * @param options - CLI options controlling output format (pretty, head, etc.) */ export declare const outputResult: (result: unknown, options: CliOptions) => void; /** * Sets up console suppression for quiet modes * * This function provides console output suppression for quiet and silent modes. * It returns an object with a restore method to re-enable console output * when needed. * * @param isQuiet - Whether to suppress console output * @returns Object with restore method to re-enable console output */ export declare const setupConsoleSuppression: (isQuiet: boolean) => { restore: () => void; }; /** * Generates default CLI examples for a given tool name * * This function creates a set of example commands that demonstrate common * usage patterns for WS-Dottie CLI tools. It includes both basic and * advanced examples to help users understand the tool's capabilities. * * @param toolName - Name of the CLI tool (e.g., "fetch-dottie", "fetch-native") * @param additionalExamples - Additional examples to include * @returns Array of example command strings */ export declare const generateDefaultExamples: (toolName: string, additionalExamples?: string[]) => string[]; /** * Generates CLI examples showing different fetch strategies * * This function creates examples that demonstrate the different fetch strategies * available in the CLI tool, including native/JSONP and validation options. * * @returns Array of example command strings */ export declare const generateExamples: () => string[]; /** * Generates help text with strategy examples and available functions * * This function creates comprehensive help text for the CLI tool, * including examples of different fetch strategies and a list of all available functions. * * @param toolName - Name of the CLI tool * @param examples - Array of example commands to include * @returns Formatted help text string */ export declare const generateHelpText: (_toolName: string, _examples?: string[]) => string; //# sourceMappingURL=ui.d.ts.map