basant307/AI_Governance_Project
048
1/**2 * @license3 * Copyright 2025 Google LLC4 * SPDX-License-Identifier: Apache-2.05 */6 7import { type CommandModule } from 'yargs';8import { SettingScope } from '../../config/settings.js';9import { getErrorMessage } from '../../utils/errors.js';10import { writeStdoutLine, writeStderrLine } from '../../utils/stdioHelpers.js';11import { getExtensionManager, resolveExtensionCommandScope } from './utils.js';12import { t } from '../../i18n/index.js';13 14interface DisableArgs {15 name: string;16 scope?: string;17}18 19export async function handleDisable(args: DisableArgs) {20 const extensionManager = await getExtensionManager();21 try {22 const scope = resolveExtensionCommandScope(args.scope);23 await extensionManager.disableExtension(args.name, scope);24 writeStdoutLine(25 t('Extension "{{name}}" successfully disabled for scope "{{scope}}".', {26 name: args.name,27 scope: args.scope || SettingScope.User,28 }),29 );30 } catch (error) {31 writeStderrLine(getErrorMessage(error));32 process.exit(1);33 }34}35 36export const disableCommand: CommandModule = {37 command: 'disable [--scope] <name>',38 describe: t('Disables an extension.'),39 builder: (yargs) =>40 yargs41 .positional('name', {42 describe: t('The name of the extension to disable.'),43 type: 'string',44 })45 .option('scope', {46 describe: t('The scope to disable the extenison in.'),47 type: 'string',48 default: SettingScope.User,49 })50 .check((argv) => {51 resolveExtensionCommandScope(argv.scope as string | undefined);52 return true;53 }),54 handler: async (argv) => {55 await handleDisable({56 name: argv['name'] as string,57 scope: argv['scope'] as string,58 });59 },60};61 