refactor: share managed runtime install policy parsing

This commit is contained in:
Andrey Avtomonov 2026-05-11 12:00:01 +02:00
parent f9806e69c7
commit f30f4d688d
3 changed files with 31 additions and 12 deletions

View file

@ -15,6 +15,19 @@ import {
export type KtxManagedPythonInstallPolicy = 'prompt' | 'auto' | 'never';
export function runtimeInstallPolicyFromFlags(options: {
yes?: boolean;
input?: boolean;
}): KtxManagedPythonInstallPolicy {
if (options.yes === true && options.input === false) {
throw new Error('Choose only one runtime install mode: --yes or --no-input');
}
if (options.yes === true) {
return 'auto';
}
return options.input === false ? 'never' : 'prompt';
}
export interface ManagedPythonCommandRuntime {
layout: ManagedPythonRuntimeLayout;
manifest: InstalledKtxRuntimeManifest;