feat: implement 'locate' command for resource-to-module mapping#1081
feat: implement 'locate' command for resource-to-module mapping#1081AshokThangavel wants to merge 6 commits intointersystems:mainfrom
Conversation
- Added 'locate' (alias 'loc') to identify the owning module of a resource. - Uses %IPM.ExtensionBase.Utils:GetHomeModuleName for reliable lookup. - Formatted output to match 'list' command (Name + Version). - Added unit tests for various resource types (.cls, .inc). - Validated handling of various resource types (.inc, .cls). - Confirmed graceful error handling for missing arguments and non-existent resources.
isc-kiyer
left a comment
There was a problem hiding this comment.
@AshokThangavel Thanks for contributing this! Just a few small notes
src/cls/IPM/Main.cls
Outdated
|
|
||
| <command name="locate" aliases="loc"> | ||
| <description>Find the module that owns a specific resource.</description> | ||
| <parameter name="resource" description="resource: The full name of the resource (e.g., My.Class.cls, Utils.inc)." /> |
There was a problem hiding this comment.
The parameter should be marked required
There was a problem hiding this comment.
Thank you. I've updated the parameter as required.
src/cls/IPM/Main.cls
Outdated
| ClassMethod Locate(ByRef CommandInfo) | ||
| { | ||
| set resource = $get(CommandInfo("parameters","resource")) | ||
| if resource="" { |
There was a problem hiding this comment.
This won't be needed once the parameter is marked required
There was a problem hiding this comment.
removed the condition as well
src/cls/IPM/Main.cls
Outdated
| <example description="Show details of history item with ID 3 and information for each undergone lifecyle phase">history details 3 -phases</example> | ||
| </command> | ||
|
|
||
| <command name="locate" aliases="loc"> |
There was a problem hiding this comment.
Nit: I would call this locate-resource with no alias since locate is a bit ambiguous and seems to overlap with search
There was a problem hiding this comment.
Thank you. I've updated the command from locate to locate-resource
src/cls/IPM/Main.cls
Outdated
| } | ||
| set moduleName = ##class(%IPM.ExtensionBase.Utils).GetHomeModuleName(resource) | ||
| if (moduleName="") { | ||
| write $$$FormattedLine($$$Red, "Resource '"_ resource_"' is not currently mapped to an installed module.") |
There was a problem hiding this comment.
Nit: I would replace "mapped to" as "part of" since mappings are an overloaded term at the IRIS level
There was a problem hiding this comment.
fixed the message string!
* **Rename** `locate` command to `locate-resource` and **remove alias** per maintainer feedback to avoid ambiguity with system commands. * **Update** error message to use "part of" instead of "mapped to" to avoid confusion with InterSystems IRIS mapping terminology.
| Method TestLocateCommand() | ||
| { | ||
| do $$$LogMessage("Testing 'loc' alias with .inc resource") | ||
| set status = ..RunCommand("loc %IPM.Common.inc") |
There was a problem hiding this comment.
I believe all these commands will need to be changed to locate-resource
There was a problem hiding this comment.
Updated the unit test code. Thank you!
CHANGELOG.md
Outdated
|
|
||
| ### Added | ||
| - #1024: Added flag -export-python-deps to publish command | ||
| - #1081: implement locate command for resource-to-module mapping |
There was a problem hiding this comment.
Nit: capitalize "implement" and move to 0.10.7
There was a problem hiding this comment.
Moved to 1.10.7 release. Thank you!
There was a problem hiding this comment.
Looks like you need to pull from main to resolve the conflict here.
There was a problem hiding this comment.
pulled from main and resolved the conflicts as well. Thank you!
Add
locatecommand to identify resource owner modulesDescription
This PR introduces the
locatecommand (aliasloc) to the IPM shell. It allows developers to quickly identify which module "owns" a specific resource (Class, Routine, Include file, etc.). Thelocatecommand provides a native CLI wrapper around the existingFindHomeModulelogic to get the owning module and its current version in a format consistent with thelistcommand.fixes: #1073
Key Features
locateand the shorthandloc..cls,.inc,.mac, and other registered resource types.<ModuleName> <Version>.Unit Test
A new test suite
TestLocateCommandwas added to verify the command's behavior across different scenarios.Unit Test Results:
loc %IPM.Common.increturns the correct module.locate %IPM.Main.clsreturns the correct module.