(program: Command)
| 7 | import type { Command } from 'commander'; |
| 8 | |
| 9 | export function viewCommand(program: Command) { |
| 10 | program |
| 11 | .command('view [directory]') |
| 12 | .description('Start browser UI') |
| 13 | .option( |
| 14 | '-p, --port <number>', |
| 15 | 'Port number', |
| 16 | (val) => Number.parseInt(val, 10), |
| 17 | getDefaultPort(), |
| 18 | ) |
| 19 | .option('-y, --yes', 'Skip confirmation and auto-open the URL') |
| 20 | .option('-n, --no', 'Skip confirmation and do not open the URL') |
| 21 | .option('--filter-description <pattern>', 'Filter evals by description using a regex pattern') |
| 22 | .option('--env-file, --env-path <path>', 'Path to .env file') |
| 23 | .action( |
| 24 | async ( |
| 25 | directory: string | undefined, |
| 26 | cmdObj: { |
| 27 | port: number; |
| 28 | yes: boolean; |
| 29 | no: boolean; |
| 30 | apiBaseUrl?: string; |
| 31 | envPath?: string; |
| 32 | filterDescription?: string; |
| 33 | } & Command, |
| 34 | ) => { |
| 35 | setupEnv(cmdObj.envPath); |
| 36 | |
| 37 | if (cmdObj.filterDescription) { |
| 38 | logger.warn( |
| 39 | 'The --filter-description option is deprecated and not longer supported. The argument will be ignored.', |
| 40 | ); |
| 41 | } |
| 42 | |
| 43 | if (directory) { |
| 44 | setConfigDirectoryPath(directory); |
| 45 | } |
| 46 | // Determine browser behavior |
| 47 | const browserBehavior = cmdObj.yes |
| 48 | ? BrowserBehavior.OPEN |
| 49 | : cmdObj.no |
| 50 | ? BrowserBehavior.SKIP |
| 51 | : BrowserBehavior.ASK; |
| 52 | |
| 53 | await startServer(cmdObj.port, browserBehavior); |
| 54 | }, |
| 55 | ); |
| 56 | } |
no test coverage detected
searching dependent graphs…