MCPcopy
hub / github.com/promptfoo/promptfoo / viewCommand

Function viewCommand

src/commands/view.ts:9–56  ·  view source on GitHub ↗
(program: Command)

Source from the content-addressed store, hash-verified

7import type { Command } from 'commander';
8
9export 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}

Callers 2

view.test.tsFile · 0.90
mainFunction · 0.90

Calls 4

getDefaultPortFunction · 0.90
setConfigDirectoryPathFunction · 0.90
startServerFunction · 0.90
setupEnvFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…