Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- #1081: implement locate command for resource-to-module mapping
Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to 1.10.7 release. Thank you!

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor Author

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!


### Fixed
- #996: Ensure COS commands execute in exec under a dedicated, isolated context
Expand Down
23 changes: 23 additions & 0 deletions src/cls/IPM/Main.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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-resource">
<description>Find the module that owns a specific resource.</description>
<parameter name="resource" required="true" 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-resource %IPM.Main.cls</example>
<example description="Finds the module containing the specified include file.">locate-resource %IPM.Common.inc</example>
</command>

</commands>
}

Expand Down Expand Up @@ -1033,6 +1040,8 @@ ClassMethod ShellInternal(
do ..Information(.tCommandInfo)
} elseif (tCommandInfo = "history") {
do ..History(.tCommandInfo)
} elseif (tCommandInfo = "locate-resource") {
do ..LocateResource(.tCommandInfo)
}
} catch pException {
if (pException.Code = $$$ERCTRLC) {
Expand Down Expand Up @@ -4051,6 +4060,20 @@ ClassMethod Update(ByRef pCommandInfo)
}
}

ClassMethod LocateResource(ByRef CommandInfo)
{
set resource = $get(CommandInfo("parameters","resource"))
set moduleName = ##class(%IPM.ExtensionBase.Utils).GetHomeModuleName(resource)
if (moduleName="") {
write $$$FormattedLine($$$Red, "Resource '"_ resource_"' is not currently part of 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())
Expand Down
19 changes: 19 additions & 0 deletions tests/unit_tests/Test/PM/Unit/CLI.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe all these commands will need to be changed to locate-resource

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the unit test code. Thank you!

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")
}

}