From a8e3bc282ac56d49da851bd2985e6ca8f320c477 Mon Sep 17 00:00:00 2001 From: Ramon Brullo Date: Fri, 1 Nov 2024 19:30:17 +0100 Subject: [PATCH] remove cmd --- src/cli/cmd-remove.ts | 71 +++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 40 deletions(-) diff --git a/src/cli/cmd-remove.ts b/src/cli/cmd-remove.ts index 93e0e8a8..712c272a 100644 --- a/src/cli/cmd-remove.ts +++ b/src/cli/cmd-remove.ts @@ -11,14 +11,9 @@ import { workDirOpt } from "./opt-wd"; import { ResultCodes } from "./result-codes"; import { mustBeDomainName } from "./validators"; -const packageNameArg = new Argument( - "", - "Name of the package to remove" -).argParser(mustBeDomainName); - -const otherPackageNamesArg = new Argument( - "[otherPkgs...]", - "Names of additional packages to remove" +const packageNamesArg = new Argument( + "...", + "Names of the packages to remove" ).argParser(eachValue(mustBeDomainName)); /** @@ -43,42 +38,38 @@ export function makeRemoveCmd( ); return new Command("remove") - .aliases(["rm", "uninstall"]) - .addArgument(packageNameArg) - .addArgument(otherPackageNamesArg) + .aliases(["rm", "r", "un", "unlink", "uninstall"]) + .addArgument(packageNamesArg) .addOption(workDirOpt) - .description("remove package from manifest json") + .summary("remove dependency from project") + .description( + `Remove one or more dependencies from a project. +openupm remove com.my.package` + ) .action( - withErrorLogger( - log, - async function (packageName, otherPackageNames, options) { - const packageNames = [packageName, ...otherPackageNames]; - - const projectDir = options.chdir; + withErrorLogger(log, async function (packageNames, options) { + const projectDir = options.chdir; - const removeResult = await removeDependencies( - projectDir, - packageNames - ).promise; - if (removeResult.isErr()) { - logError(log, removeResult.error); - return process.exit(ResultCodes.Error); - } - const removedPackages = removeResult.value; + const removeResult = await removeDependencies(projectDir, packageNames) + .promise; + if (removeResult.isErr()) { + logError(log, removeResult.error); + return process.exit(ResultCodes.Error); + } + const removedPackages = removeResult.value; - removedPackages.forEach((removedPackage) => { - log.notice( - "", - `Removed "${makePackageSpec( - removedPackage.name, - removedPackage.version - )}".` - ); - }); + removedPackages.forEach((removedPackage) => { + log.notice( + "", + `Removed "${makePackageSpec( + removedPackage.name, + removedPackage.version + )}".` + ); + }); - // print manifest notice - log.notice("", "please open Unity project to apply changes"); - } - ) + // print manifest notice + log.notice("", "please open Unity project to apply changes"); + }) ); }