mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-26 05:50:56 -07:00
Fix extensions enablement bugs (#8797)
This commit is contained in:
@@ -11,12 +11,16 @@ import { getErrorMessage } from '../../utils/errors.js';
|
||||
|
||||
interface DisableArgs {
|
||||
name: string;
|
||||
scope: SettingScope;
|
||||
scope?: string;
|
||||
}
|
||||
|
||||
export function handleDisable(args: DisableArgs) {
|
||||
try {
|
||||
disableExtension(args.name, args.scope);
|
||||
if (args.scope?.toLowerCase() === 'workspace') {
|
||||
disableExtension(args.name, SettingScope.Workspace);
|
||||
} else {
|
||||
disableExtension(args.name, SettingScope.User);
|
||||
}
|
||||
console.log(
|
||||
`Extension "${args.name}" successfully disabled for scope "${args.scope}".`,
|
||||
);
|
||||
@@ -39,13 +43,28 @@ export const disableCommand: CommandModule = {
|
||||
describe: 'The scope to disable the extenison in.',
|
||||
type: 'string',
|
||||
default: SettingScope.User,
|
||||
choices: [SettingScope.User, SettingScope.Workspace],
|
||||
})
|
||||
.check((_argv) => true),
|
||||
.check((argv) => {
|
||||
if (
|
||||
argv.scope &&
|
||||
!Object.values(SettingScope)
|
||||
.map((s) => s.toLowerCase())
|
||||
.includes((argv.scope as string).toLowerCase())
|
||||
) {
|
||||
throw new Error(
|
||||
`Invalid scope: ${argv.scope}. Please use one of ${Object.values(
|
||||
SettingScope,
|
||||
)
|
||||
.map((s) => s.toLowerCase())
|
||||
.join(', ')}.`,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
handler: (argv) => {
|
||||
handleDisable({
|
||||
name: argv['name'] as string,
|
||||
scope: argv['scope'] as SettingScope,
|
||||
scope: argv['scope'] as string,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -11,13 +11,16 @@ import { SettingScope } from '../../config/settings.js';
|
||||
|
||||
interface EnableArgs {
|
||||
name: string;
|
||||
scope?: SettingScope;
|
||||
scope?: string;
|
||||
}
|
||||
|
||||
export function handleEnable(args: EnableArgs) {
|
||||
try {
|
||||
const scope = args.scope ? args.scope : SettingScope.User;
|
||||
enableExtension(args.name, scope);
|
||||
if (args.scope?.toLowerCase() === 'workspace') {
|
||||
enableExtension(args.name, SettingScope.Workspace);
|
||||
} else {
|
||||
enableExtension(args.name, SettingScope.User);
|
||||
}
|
||||
if (args.scope) {
|
||||
console.log(
|
||||
`Extension "${args.name}" successfully enabled for scope "${args.scope}".`,
|
||||
@@ -45,13 +48,28 @@ export const enableCommand: CommandModule = {
|
||||
describe:
|
||||
'The scope to enable the extenison in. If not set, will be enabled in all scopes.',
|
||||
type: 'string',
|
||||
choices: [SettingScope.User, SettingScope.Workspace],
|
||||
})
|
||||
.check((_argv) => true),
|
||||
.check((argv) => {
|
||||
if (
|
||||
argv.scope &&
|
||||
!Object.values(SettingScope)
|
||||
.map((s) => s.toLowerCase())
|
||||
.includes((argv.scope as string).toLowerCase())
|
||||
) {
|
||||
throw new Error(
|
||||
`Invalid scope: ${argv.scope}. Please use one of ${Object.values(
|
||||
SettingScope,
|
||||
)
|
||||
.map((s) => s.toLowerCase())
|
||||
.join(', ')}.`,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
handler: (argv) => {
|
||||
handleEnable({
|
||||
name: argv['name'] as string,
|
||||
scope: argv['scope'] as SettingScope,
|
||||
scope: argv['scope'] as string,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user