-
Notifications
You must be signed in to change notification settings - Fork 27
feat: implement 'locate-resource' command for resource-to-module mapping #1081
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 2 commits
cc88cbd
85019bc
b11a1db
c53ff92
370d931
c292317
18a0425
629307f
4b2ee0b
53673a3
037df5c
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 |
|---|---|---|
|
|
@@ -791,6 +791,13 @@ generate /my/path -export 00000,PacketName2,IgnorePacket2^00000,PacketName3,Igno | |
| <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"> | ||
|
||
| <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)." /> | ||
|
||
| <example description="Finds the module containing the specified class.">locate %IPM.Main.cls</example> | ||
| <example description="Finds the module containing the specified include file.">loc %IPM.Common.inc</example> | ||
| </command> | ||
|
|
||
| </commands> | ||
| } | ||
|
|
||
|
|
@@ -1033,6 +1040,8 @@ ClassMethod ShellInternal( | |
| do ..Information(.tCommandInfo) | ||
| } elseif (tCommandInfo = "history") { | ||
| do ..History(.tCommandInfo) | ||
| } elseif (tCommandInfo = "locate") { | ||
| do ..Locate(.tCommandInfo) | ||
| } | ||
| } catch pException { | ||
| if (pException.Code = $$$ERCTRLC) { | ||
|
|
@@ -4051,6 +4060,23 @@ ClassMethod Update(ByRef pCommandInfo) | |
| } | ||
| } | ||
|
|
||
| ClassMethod Locate(ByRef CommandInfo) | ||
| { | ||
| set resource = $get(CommandInfo("parameters","resource")) | ||
| if resource="" { | ||
|
||
| $$$ThrowOnError($$$ERROR($$$GeneralError,"Resource name is required.")) | ||
| } | ||
| set moduleName = ##class(%IPM.ExtensionBase.Utils).GetHomeModuleName(resource) | ||
| if (moduleName="") { | ||
| write $$$FormattedLine($$$Red, "Resource '"_ resource_"' is not currently mapped to an installed module.") | ||
|
||
| quit | ||
| } | ||
| set showFields = "" | ||
| write ! | ||
| do ..GetListModules(,moduleName, .list) | ||
| do ..DisplayModules(.list,,,, .tModifiers) | ||
| } | ||
|
|
||
| ClassMethod GetPythonInstalledLibs(Output list) | ||
| { | ||
| set target = ##class(%File).NormalizeDirectory("python", $system.Util.ManagerDirectory()) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -329,4 +329,23 @@ Method TestUninstallWithoutModuleName() | |
| do $$$AssertNotTrue(exists, "Module removed successfully.") | ||
| } | ||
|
|
||
| Method TestLocateCommand() | ||
| { | ||
| do $$$LogMessage("Testing 'loc' alias with .inc resource") | ||
| set status = ..RunCommand("loc %IPM.Common.inc") | ||
|
||
| do $$$AssertStatusOK(status, "Alias 'loc' executed successfully") | ||
|
|
||
| do $$$LogMessage("Testing 'locate' command with .cls resource") | ||
| set status = ..RunCommand("locate %IPM.Main.cls") | ||
| do $$$AssertStatusOK(status, "Command 'locate' executed successfully") | ||
|
|
||
| do $$$LogMessage("Testing locate with non-existing resource") | ||
| set status = ..RunCommand("locate Test.Sample.inc") | ||
| do $$$AssertStatusOK(status, "Gracefully handled non-existing resource") | ||
|
|
||
| do $$$LogMessage("Testing locate without required argument") | ||
| set status = ..RunCommand("locate") | ||
| do $$$AssertStatusNotOK(status, "Handled missing argument") | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: capitalize "implement" and move to 0.10.7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to
1.10.7release. Thank you!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you need to pull from main to resolve the conflict here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pulled from main and resolved the conflicts as well. Thank you!