import { bash } from '../szci.bash.ts'; import { logger } from '../szci.logging.ts'; /** * Executes a wrapped command passed via CLI arguments. * Usage: szci command * * This allows running arbitrary commands through szci's bash wrapper * which handles nvm and other environment setup. */ export const command = async (): Promise => { // Skip 'deno', 'mod.ts', 'command' and get the rest const commandArgs = Deno.args.slice(1); // Skip 'command' if (commandArgs.length === 0) { logger.log('error', 'No command specified. Usage: szci command '); Deno.exit(1); } const wrappedCommand = commandArgs.join(' '); logger.log('info', `Executing command: ${wrappedCommand}`); try { await bash(wrappedCommand); logger.log('ok', 'Command executed successfully'); } catch (error) { logger.log('error', `Command failed: ${(error as Error).message}`); throw error; } };