diff --git a/CHANGELOG.md b/CHANGELOG.md index ab39ec54..2cb98a9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - #961: Adding creation of a lock file for a module by using the `-create-lockfile` flag on install. - #959: In ORAS repos, external name can now be used interchangeably with (default) name for `install` and `update`, i.e. a module published with its (default) name can be installed using its external name. - #951: The `unpublish` command will skip user confirmation prompt if the `-force` flag is provided. +- #1018: Require module name for uninstall when not using the -all flag ### Changed - #316: All parameters, except developer mode, included with a `load`, `install` or `update` command will be propagated to dependencies diff --git a/src/cls/IPM/Main.cls b/src/cls/IPM/Main.cls index 0cbe438d..a9392916 100644 --- a/src/cls/IPM/Main.cls +++ b/src/cls/IPM/Main.cls @@ -2450,7 +2450,10 @@ ClassMethod Uninstall(ByRef pCommandInfo) [ Internal ] $$$ThrowOnError(##class(%IPM.Utils.Module).UninstallAll(tForce,.tParams)) return } else { - set tModuleName = pCommandInfo("parameters","module") + set tModuleName = $get(pCommandInfo("parameters","module")) + if (tModuleName = "") { + $$$ThrowOnError($$$ERROR($$$GeneralError, "A module name must be specified for uninstall unless the -all flag is used.")) + } if (tModuleName = $$$IPMModuleName) { $$$ThrowOnError(..CheckModuleNamespace()) } diff --git a/tests/unit_tests/Test/PM/Unit/CLI.cls b/tests/unit_tests/Test/PM/Unit/CLI.cls index a25bcd03..7cf0e6ca 100644 --- a/tests/unit_tests/Test/PM/Unit/CLI.cls +++ b/tests/unit_tests/Test/PM/Unit/CLI.cls @@ -219,10 +219,12 @@ Method CompareModifiers( } } -Method RunCommand(pCommand As %String) +/// This method returns the %Status for checking the success or failure of executed commands. +Method RunCommand(pCommand As %String) As %Status { - do ##class(%IPM.Main).Shell(pCommand) + set status = ##class(%IPM.Main).Shell(pCommand) do $$$LogMessage("Run command: "_pCommand) + return status } Method AssertNoException(pCommand As %String) @@ -313,4 +315,18 @@ Method TestListPython() As %Status quit sc } +Method TestUninstallWithoutModuleName() +{ + do $$$LogMessage("Run Uninstall command without module name") + set status = ..RunCommand("uninstall") + do $$$AssertStatusNotOK(status, $system.Status.GetErrorText(status)) + set status = ..RunCommand("install objectscript-math") + do $$$AssertStatusOK(status, "objectscript-math module installed successfully.") + set exists = ##class(%IPM.Storage.Module).NameExists("objectscript-math") + do $$$AssertTrue(exists, "objectscript-math Module exists in storage after installation.") + do ..RunCommand("uninstall objectscript-math") + set exists = ##class(%IPM.Storage.Module).NameExists("objectscript-math") + do $$$AssertNotTrue(exists, "Module removed successfully.") +} + }