(parent: Command, overrides?: Partial<VisDeps>)
| 101 | } |
| 102 | |
| 103 | export function registerVisCommand(parent: Command, overrides?: Partial<VisDeps>): void { |
| 104 | parent |
| 105 | .command('vis') |
| 106 | .description('Launch the session visualizer in your browser.') |
| 107 | .option('--port <number>', 'Port to bind. Default: auto-pick a free port.') |
| 108 | .option('--host <host>', 'Host to bind. Default: 127.0.0.1.') |
| 109 | .option('--no-open', 'Do not open the browser automatically.') |
| 110 | .argument('[sessionId]', 'Open directly to this session.') |
| 111 | .action( |
| 112 | async ( |
| 113 | sessionId: string | undefined, |
| 114 | options: { port?: string; host?: string; open?: boolean }, |
| 115 | ) => { |
| 116 | const port = options.port === undefined ? undefined : Number.parseInt(options.port, 10); |
| 117 | await handleVis(createDefaultVisDeps(overrides), { |
| 118 | open: options.open !== false, |
| 119 | ...(port === undefined || Number.isNaN(port) ? {} : { port }), |
| 120 | ...(options.host === undefined ? {} : { host: options.host }), |
| 121 | ...(sessionId === undefined ? {} : { sessionId }), |
| 122 | }); |
| 123 | }, |
| 124 | ); |
| 125 | } |
| 126 | |
| 127 | function createDefaultVisDeps(overrides: Partial<VisDeps> = {}): VisDeps { |
| 128 | return { |
no test coverage detected