UNPKG

@umbrelladocs/rdformat-validator

Version:

Validate and fix Reviewdog Diagnostic Format (RD Format) - A comprehensive library and CLI tool for validating JSON data against the Reviewdog Diagnostic Format specification

123 lines 3.29 kB
/** * CLI Module for RDFormat Validator * Provides command-line interface functionality for validating RDFormat data */ import { RDFormatValidatorOptions } from '../types/validation'; /** * CLI options interface extending the base validator options */ export interface CLIOptions extends RDFormatValidatorOptions { /** Enable automatic fixing of common issues */ fix?: boolean; /** Output file path (default: stdout) */ output?: string; /** Enable verbose output */ verbose?: boolean; /** Enable silent mode (suppress non-error output) */ silent?: boolean; /** Output format: 'json' or 'text' */ format?: 'json' | 'text'; /** Input files to validate */ files?: string[]; } /** * CLI result interface for structured output */ export interface CLIResult { /** Overall success status */ success: boolean; /** Number of files processed */ filesProcessed: number; /** Number of valid files */ validFiles: number; /** Number of invalid files */ invalidFiles: number; /** Total number of errors across all files */ totalErrors: number; /** Total number of warnings across all files */ totalWarnings: number; /** Total number of fixes applied */ totalFixes: number; /** Detailed results per file */ fileResults: Array<{ file: string; valid: boolean; errors: number; warnings: number; fixes: number; errorDetails?: Array<{ path: string; message: string; code: string; }>; warningDetails?: Array<{ path: string; message: string; code: string; }>; fixDetails?: Array<{ path: string; message: string; }>; }>; } /** * Main CLI class that handles command-line operations */ export declare class CLI { private program; private validator; constructor(); /** * Set up the command-line interface structure and options */ private setupCommands; /** * Parse command-line arguments and convert to CLIOptions */ private parseOptions; /** * Main CLI execution method * @param options - Parsed CLI options * @returns Exit code (0 for success, non-zero for failure) */ run(options: CLIOptions): Promise<number>; /** * Process multiple files */ private processFiles; /** * Process a single file */ private processFile; /** * Process input from stdin */ private processStdin; /** * Output the validation results */ private outputResult; /** * Write fixed data to output file when fixing is enabled */ private writeFixedData; /** * Format results as human-readable text */ private formatTextOutput; /** * Parse command-line arguments and execute */ parseAndExecute(args: string[]): Promise<number>; } /** * Create and return a new CLI instance */ export declare function createCLI(): CLI; /** * Main entry point for CLI execution * @param args - Command-line arguments (defaults to process.argv) */ export declare function main(args?: string[]): Promise<number>; //# sourceMappingURL=index.d.ts.map