Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
26 changes: 26 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" aliases="loc">
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: I would call this locate-resource with no alias since locate is a bit ambiguous and seems to overlap with search

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.

Thank you. I've updated the command from locate to locate-resource

<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)." />
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.

The parameter should be marked required

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.

Thank you. I've updated the parameter as required.

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

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -4051,6 +4060,23 @@ ClassMethod Update(ByRef pCommandInfo)
}
}

ClassMethod Locate(ByRef CommandInfo)
{
set resource = $get(CommandInfo("parameters","resource"))
if resource="" {
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.

This won't be needed once the parameter is marked required

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.

removed the condition as well

$$$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.")
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: I would replace "mapped to" as "part of" since mappings are an overloaded term at the IRIS level

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.

fixed the message string!

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

}