-
Notifications
You must be signed in to change notification settings - Fork 27
feat: add semantic sorting and shortcuts to list-installed #1079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 8 commits
c30fdef
b913dc8
fcc4781
5df4bc8
faccdd6
aab50ef
d92dd52
3168294
662f4e0
8aff3fc
71049cd
1d41039
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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." /> | ||
|
|
||
|
|
@@ -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" /> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default sort (if flag not provided) should be ascending by name. Should indicate that here. |
||
| </command> | ||
|
|
||
| <command name="list-dependents" aliases="dependents"> | ||
|
|
@@ -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) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests should read output and confirm its sorted in the correct order. Should also test ascending and descending for each sort modifier |
||
| 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") | ||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.