Skip to content
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 47 additions & 0 deletions src/cls/IPM/Main.cls
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,17 @@ reinstall -env /path/to/env1.json;/path/to/env2.json example-package
list -python
</example>

<example description="Shortforms: n, d, v. Add '-d' for descending (e.g., d-d).">
list -s [name|date|version]
</example>

<example description="Shows installed modules in descending order">
list -s name-desc
</example>
<example description="Shows installed modules in decending based on the installation date">
list -s d-d
</example>

<!-- Parameters -->
<parameter name="searchString" description="Search string, * can be used." />

Expand All @@ -538,6 +549,7 @@ reinstall -env /path/to/env1.json;/path/to/env2.json example-package
<modifier name="showupstream" aliases="su" description="If specified, show the latest version for each module in configured repos if it's different than the local version." />
<modifier name="repository" aliases="repo" value="true" description="If specified, only show modules installed that belong to the provided repository." />
<modifier name="python" aliases="py" description="If specified, lists installed Embedded Python libraries instead of IPM modules." />
<modifier name="sort" aliases="s" value="true" description="Sort the list. Options: name, name-desc, date, date-desc, version, version-desc" />
</command>

<command name="list-dependents" aliases="dependents">
Expand Down Expand Up @@ -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)
}
}
Expand Down
12 changes: 12 additions & 0 deletions tests/unit_tests/Test/PM/Unit/CLI.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

}