diff --git a/CHANGELOG.md b/CHANGELOG.md
index 33ae8581e..24152bca0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,11 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
## [0.10.7] - Unreleased
### Added
- #992: Implement automatic history purge logic
- #973: Enables CORS and JWT configuration for WebApplications in module.xml
+- #1079: add semantic sorting and shortcuts to list-installed
### Fixed
- #1001: The `unmap` and `enable` commands will now only activate CPF merge once after all namespaces have been configured instead after every namespace
diff --git a/src/cls/IPM/Main.cls b/src/cls/IPM/Main.cls
index 64f7e2819..c72be4d7f 100644
--- a/src/cls/IPM/Main.cls
+++ b/src/cls/IPM/Main.cls
@@ -527,6 +527,17 @@ reinstall -env /path/to/env1.json;/path/to/env2.json example-package
list -python
+
+ list -s [name|date|version]
+
+
+
+ list -s name-desc
+
+
+ list -s d-d
+
+
@@ -538,6 +549,7 @@ reinstall -env /path/to/env1.json;/path/to/env2.json example-package
+
@@ -2809,6 +2821,41 @@ ClassMethod ListInstalled(ByRef pCommandInfo) [ Private ]
}
}
merge tModifiers = pCommandInfo("modifiers")
+ set sortMode = $$$lcase($get(pCommandInfo("modifiers", "sort")))
+ set type = $extract(sortMode, 1) // "d", "n", or "v"
+ set isDesc = (sortMode [ "-d")
+ set sortMode = $case(type, "n":"name", "d":"date", "v":"version", :"name")
+ if isDesc {
+ set sortMode = sortMode_"-desc"
+ }
+ set newlist =""
+ if sortMode'="" {
+ for i=1:1:list {
+ set entry = list(i)
+ set name = $listget(entry,1)
+ set entry = entry_$listbuild(i)
+ if sortMode["name"{
+ set newlist($$$lcase(name))=entry
+ }
+ if sortMode["date" {
+ set date = $listget(entry,6)
+ set newlist(date)=entry
+ }
+ if sortMode["version" {
+ set newlist($listfromstring($listget(entry,2),"."))=entry
+ }
+ kill list(i)
+ }
+ set direction = $select(sortMode [ "desc": -1, 1: 1)
+ set mod = ""
+ if $data(newlist)>1 {
+ // create new list based on the sorting
+ for {
+ set mod = $order(newlist(mod),direction,data) quit:mod=""
+ set list($increment(mlist))=data
+ }
+ }
+ }
do ..DisplayModules(.list,,,, .tModifiers)
}
}
diff --git a/tests/unit_tests/Test/PM/Unit/CLI.cls b/tests/unit_tests/Test/PM/Unit/CLI.cls
index 8e9f2329a..49084315a 100644
--- a/tests/unit_tests/Test/PM/Unit/CLI.cls
+++ b/tests/unit_tests/Test/PM/Unit/CLI.cls
@@ -352,4 +352,16 @@ Method TestUninstallWithoutModuleName()
do $$$AssertNotTrue(exists, "Module removed successfully.")
}
+Method TestListSortingFlags()
+{
+ do $$$LogMessage("Testing list-installed sorting flags")
+ set status = ..RunCommand("list")
+ set status = ..RunCommand("list -s n")
+ do $$$AssertStatusOK(status, "Sort by name command executed successfully")
+ set status = ..RunCommand("list -s v-d")
+ do $$$AssertStatusOK(status, "Sort by version descending executed successfully")
+ set status = ..RunCommand("list -s d-d")
+ do $$$AssertStatusOK(status, "Sort by date descending executed successfully")
+}
+
}