Skip to content

Commit

Permalink
feat: added -o/--open option to genkit start to pop up a browser (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelgj authored Nov 12, 2024
1 parent 4593450 commit bd1b7d6
Showing 1 changed file with 6 additions and 1 deletion.
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]);
});

0 comments on commit bd1b7d6

Please sign in to comment.