Skip to content

Commit 563545f

Browse files
committed
fix(cli): handle init -e as full environment value
1 parent 3a239d4 commit 563545f

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

packages/cli/src/commands/init.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,28 @@ function ensureGitRepository(): void {
4040
}
4141

4242
interface InitOptions {
43-
environment?: EnvironmentCode[];
43+
environment?: EnvironmentCode[] | string;
4444
all?: boolean;
4545
phases?: string;
4646
}
4747

48+
function normalizeEnvironmentOption(
49+
environment: EnvironmentCode[] | string | undefined
50+
): EnvironmentCode[] {
51+
if (!environment) {
52+
return [];
53+
}
54+
55+
if (Array.isArray(environment)) {
56+
return environment;
57+
}
58+
59+
return environment
60+
.split(',')
61+
.map(value => value.trim())
62+
.filter((value): value is EnvironmentCode => value.length > 0);
63+
}
64+
4865
export async function initCommand(options: InitOptions) {
4966
const configManager = new ConfigManager();
5067
const templateManager = new TemplateManager();
@@ -69,7 +86,7 @@ export async function initCommand(options: InitOptions) {
6986
}
7087
}
7188

72-
let selectedEnvironments: EnvironmentCode[] = options.environment || [];
89+
let selectedEnvironments: EnvironmentCode[] = normalizeEnvironmentOption(options.environment);
7390
if (selectedEnvironments.length === 0) {
7491
ui.info('AI Environment Setup');
7592
selectedEnvironments = await environmentSelector.selectEnvironments();
@@ -163,4 +180,3 @@ export async function initCommand(options: InitOptions) {
163180
ui.text(' • Run `ai-devkit phase <name>` to add more phases later');
164181
ui.text(' • Run `ai-devkit init` again to add more environments\n');
165182
}
166-

0 commit comments

Comments
 (0)