UNPKG

testify-universal-cli

Version:

Universal interactive CLI tool for scanning and executing tests across multiple programming languages

92 lines (80 loc) 2.18 kB
#!/usr/bin/env node import chalk from 'chalk'; import meow from 'meow'; import testify from './index.js'; import { logger } from './lib/utils/logger.js'; const cli = meow(` ${chalk.bold('Usage')} $ testify [options] ${chalk.bold('Options')} --marker, -m Specify test marker/tag to filter by (can be used multiple times) --runner, -r Custom test runner (instead of auto-detected default) --cwd, -c Directory to scan (defaults to current directory) --language, -l Force a specific language (python, node, ruby, go, java, rust) --debug, -d Enable debug mode with verbose logging --help Show this help --version Show version ${chalk.bold('Supported Languages')} Node.js: Jest, Vitest, Mocha Python: pytest Ruby: RSpec, Rake Test Go: go test Java: JUnit with Maven/Gradle Rust: Cargo Test ${chalk.bold('Examples')} $ testify $ testify --marker=integration $ testify --marker=fast --marker=api $ testify --runner=jest $ testify --language=ruby $ testify --debug `, { importMeta: import.meta, flags: { marker: { type: 'string', shortFlag: 'm', isMultiple: true, }, runner: { type: 'string', shortFlag: 'r', }, language: { type: 'string', shortFlag: 'l', }, cwd: { type: 'string', shortFlag: 'c', default: process.cwd() }, debug: { type: 'boolean', shortFlag: 'd', default: false } }, }); // Configure logger based on debug flag logger.setDebugMode(cli.flags.debug); // Log CLI invocation logger.debug('CLI invoked with options:', cli.flags); // Run the testify function with CLI options try { logger.info('Starting testify...'); const startTime = process.hrtime(); await testify({ cwd: cli.flags.cwd, markers: cli.flags.marker || [], runner: cli.flags.runner, language: cli.flags.language, debug: cli.flags.debug }); const [seconds, nanoseconds] = process.hrtime(startTime); const duration = seconds * 1000 + nanoseconds / 1000000; logger.success(`Testify completed in ${duration.toFixed(2)}ms`); } catch (error) { logger.error(`Failed to run testify`, error); process.exit(1); }