feat(setup): wire setup command into CLI and start command
- Register setup command in CLI index - Offer setup wizard when running `flynn start` with no config - Guard telegram log output since telegram is now optional Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { registerDoctorCommand } from './doctor.js';
|
|||||||
import { registerConfigCommand } from './config-cmd.js';
|
import { registerConfigCommand } from './config-cmd.js';
|
||||||
import { registerTuiCommand } from './tui.js';
|
import { registerTuiCommand } from './tui.js';
|
||||||
import { registerCompletionCommand } from './completion.js';
|
import { registerCompletionCommand } from './completion.js';
|
||||||
|
import { registerSetupCommand } from './setup.js';
|
||||||
|
|
||||||
export function createProgram(): Command {
|
export function createProgram(): Command {
|
||||||
const program = new Command();
|
const program = new Command();
|
||||||
@@ -23,6 +24,7 @@ export function createProgram(): Command {
|
|||||||
registerDoctorCommand(program);
|
registerDoctorCommand(program);
|
||||||
registerConfigCommand(program);
|
registerConfigCommand(program);
|
||||||
registerCompletionCommand(program);
|
registerCompletionCommand(program);
|
||||||
|
registerSetupCommand(program);
|
||||||
|
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-1
@@ -11,8 +11,25 @@ export function registerStartCommand(program: Command): void {
|
|||||||
const configPath = opts.config ?? getConfigPath();
|
const configPath = opts.config ?? getConfigPath();
|
||||||
|
|
||||||
if (!existsSync(configPath)) {
|
if (!existsSync(configPath)) {
|
||||||
|
// Offer setup wizard
|
||||||
|
const { createInterface } = await import('readline/promises');
|
||||||
|
const { createPrompter } = await import('./setup/prompts.js');
|
||||||
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
||||||
|
const p = createPrompter(rl);
|
||||||
|
const runWizard = await p.confirm(
|
||||||
|
'No configuration found. Would you like to run the setup wizard?',
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
rl.close();
|
||||||
|
|
||||||
|
if (runWizard) {
|
||||||
|
const { runSetup } = await import('./setup.js');
|
||||||
|
await runSetup(configPath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
console.error(`Config file not found: ${configPath}`);
|
console.error(`Config file not found: ${configPath}`);
|
||||||
console.error('Run "flynn doctor" to diagnose, or create a config at ~/.config/flynn/config.yaml');
|
console.error('Run "flynn setup" to create one, or "flynn doctor" to diagnose.');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user