|
| 1 | +/* |
| 2 | +* cmd.ts |
| 3 | +* |
| 4 | +* Copyright (C) 2021 by RStudio, PBC |
| 5 | +* |
| 6 | +*/ |
| 7 | +import { Command } from "cliffy/command/mod.ts"; |
| 8 | +import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts"; |
| 9 | +import { createTempContext } from "../../core/temp.ts"; |
| 10 | +import { uninstallTool } from "../tools/tools.ts"; |
| 11 | + |
| 12 | +import { info } from "log/mod.ts"; |
| 13 | + |
| 14 | +export const removeCommand = new Command() |
| 15 | + .hidden() |
| 16 | + .name("remove") |
| 17 | + .arguments("[target:string]") |
| 18 | + .arguments("<type:string> <target:string>") |
| 19 | + .option( |
| 20 | + "--no-prompt", |
| 21 | + "Do not prompt to confirm actions during installation", |
| 22 | + ) |
| 23 | + .description( |
| 24 | + "Removes an extension or global dependency.", |
| 25 | + ) |
| 26 | + .example( |
| 27 | + "Remove extension using name", |
| 28 | + "quarto remove extension <extension-name>", |
| 29 | + ) |
| 30 | + .example( |
| 31 | + "Remove TinyTeX", |
| 32 | + "quarto remove tool tinytex", |
| 33 | + ) |
| 34 | + .example( |
| 35 | + "Remove Chromium", |
| 36 | + "quarto remove tool chromium", |
| 37 | + ) |
| 38 | + .action( |
| 39 | + async (options: { prompt?: boolean }, type: string, target: string) => { |
| 40 | + await initYamlIntelligenceResourcesFromFilesystem(); |
| 41 | + const temp = createTempContext(); |
| 42 | + try { |
| 43 | + if (type.toLowerCase() === "extension") { |
| 44 | + // Install an extension |
| 45 | + // TODO: Remove extension |
| 46 | + } else if (type.toLowerCase() === "tool") { |
| 47 | + // Install a tool |
| 48 | + await uninstallTool(target); |
| 49 | + } else { |
| 50 | + // This is an unrecognized type option |
| 51 | + info( |
| 52 | + `Unrecorgnized option '${type}' - please choose 'tool' or 'extension'.`, |
| 53 | + ); |
| 54 | + } |
| 55 | + } finally { |
| 56 | + temp.cleanup(); |
| 57 | + } |
| 58 | + }, |
| 59 | + ); |
0 commit comments