From c30fdef9e546b3d320269e57faf6879df6f78f5d Mon Sep 17 00:00:00 2001 From: AshokThangavel Date: Fri, 27 Feb 2026 23:53:53 +0530 Subject: [PATCH 1/3] feat: add semantic sorting and shortcuts to list-installed - Implement -sort (-s) for name, date, and version. - Fix version collation using numeric $List segments (e.g., 0.10 > 0.2). - Add descending order support via -desc suffix (e.g., v-d, d-d). - Support power-user shortforms (n, d, v) for all sort modes. - Update help documentation with usage examples. --- src/cls/IPM/Main.cls | 47 +++++++++++++++++++++++++++ tests/unit_tests/Test/PM/Unit/CLI.cls | 12 +++++++ 2 files changed, 59 insertions(+) diff --git a/src/cls/IPM/Main.cls b/src/cls/IPM/Main.cls index 5fce52dfa..7c8b29b14 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 + @@ -2721,6 +2733,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 7cf0e6ca9..c892570d4 100644 --- a/tests/unit_tests/Test/PM/Unit/CLI.cls +++ b/tests/unit_tests/Test/PM/Unit/CLI.cls @@ -329,4 +329,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") +} + } From b913dc854550fae4cb1833fbb1d87f892b45d633 Mon Sep 17 00:00:00 2001 From: AshokThangavel Date: Fri, 27 Feb 2026 23:58:15 +0530 Subject: [PATCH 2/3] docs: changelog entry added --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8c152ed..e9bd1b884 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - #1024: Added flag -export-python-deps to publish command +- #1079: add semantic sorting and shortcuts to list-installed ### Fixed - #996: Ensure COS commands execute in exec under a dedicated, isolated context From fcc4781d569bbf4cc51d4d0718867661611e2cdf Mon Sep 17 00:00:00 2001 From: AshokThangavel Date: Thu, 5 Mar 2026 19:04:04 +0530 Subject: [PATCH 3/3] refactor: Updated the code based on review comments --- CHANGELOG.md | 7 ++++++- src/cls/IPM/Main.cls | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9bd1b884..79fae659d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,16 @@ 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 +- #1079: add semantic sorting and shortcuts to list-installed + ## [0.10.6] - Unreleased ### Added - #1024: Added flag -export-python-deps to publish command -- #1079: add semantic sorting and shortcuts to list-installed ### Fixed - #996: Ensure COS commands execute in exec under a dedicated, isolated context diff --git a/src/cls/IPM/Main.cls b/src/cls/IPM/Main.cls index 7c8b29b14..bcd36d1e7 100644 --- a/src/cls/IPM/Main.cls +++ b/src/cls/IPM/Main.cls @@ -531,7 +531,7 @@ reinstall -env /path/to/env1.json;/path/to/env2.json example-package list -s [name|date|version] - + list -s name-desc @@ -2743,13 +2743,13 @@ ClassMethod ListInstalled(ByRef pCommandInfo) [ Private ] set newlist ="" if sortMode'="" { for i=1:1:list { - set entry = list(i) + 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"{ + if sortMode["date" { set date = $listget(entry,6) set newlist(date)=entry }