2025-08-25 17:40:15 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-26 00:04:53 +02:00
|
|
|
import type { CommandModule } from 'yargs';
|
2025-08-25 17:40:15 +00:00
|
|
|
import { uninstallExtension } from '../../config/extension.js';
|
2025-08-26 14:36:55 +00:00
|
|
|
import { getErrorMessage } from '../../utils/errors.js';
|
2025-08-25 17:40:15 +00:00
|
|
|
|
|
|
|
|
interface UninstallArgs {
|
|
|
|
|
name: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function handleUninstall(args: UninstallArgs) {
|
|
|
|
|
try {
|
|
|
|
|
await uninstallExtension(args.name);
|
|
|
|
|
console.log(`Extension "${args.name}" successfully uninstalled.`);
|
|
|
|
|
} catch (error) {
|
2025-08-26 14:36:55 +00:00
|
|
|
console.error(getErrorMessage(error));
|
2025-08-25 17:40:15 +00:00
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const uninstallCommand: CommandModule = {
|
|
|
|
|
command: 'uninstall <name>',
|
|
|
|
|
describe: 'Uninstalls an extension.',
|
|
|
|
|
builder: (yargs) =>
|
|
|
|
|
yargs
|
|
|
|
|
.positional('name', {
|
|
|
|
|
describe: 'The name of the extension to uninstall.',
|
|
|
|
|
type: 'string',
|
|
|
|
|
})
|
|
|
|
|
.check((argv) => {
|
|
|
|
|
if (!argv.name) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
'Please include the name of the extension to uninstall as a positional argument.',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}),
|
|
|
|
|
handler: async (argv) => {
|
|
|
|
|
await handleUninstall({
|
|
|
|
|
name: argv['name'] as string,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
};
|