Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion genkit-tools/cli/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ import { logger } from '@genkit-ai/tools-common/utils';
import { spawn } from 'child_process';
import { Command } from 'commander';
import getPort, { makeRange } from 'get-port';
import open from 'open';
import { startManager } from '../utils/manager-utils';

interface RunOptions {
noui?: boolean;
port?: string;
open?: boolean;
}

/** Command to run code in dev mode and/or the Dev UI. */
export const start = new Command('start')
.description('runs a command in Genkit dev mode')
.option('-n, --noui', 'do not start the Dev UI', false)
.option('-p, --port', 'port for the Dev UI')
.option('-o, --open', 'Open the browser on UI start up')
.action(async (options: RunOptions) => {
let runtimePromise = Promise.resolve();
if (start.args.length > 0) {
Expand Down Expand Up @@ -69,7 +72,9 @@ export const start = new Command('start')
uiPromise = startManager(true).then((manager) =>
startServer(manager, port)
);
if (options.open) {
open(`http://localhost:${port}`);
}
}

await Promise.all([runtimePromise, uiPromise]);
});
Loading