Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- #950: Added support for listing installed Python packages using `list -python`, `list -py` and `list-installed -python`
- #822: The CPF resource processor now supports system expressions and macros in CPF merge files
- #578 Added functionality to record and display IPM history of install, uninstall, load, and update
- #994: prevent crash when target namespace lacks IPM mappings

### Changed
- #316: All parameters, except developer mode, included with a `load`, `install` or `update` command will be propagated to dependencies
Expand Down
28 changes: 24 additions & 4 deletions src/cls/IPM/Main.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,11 @@ ClassMethod Namespace(ByRef pCommandInfo) [ Internal ]
set name = $translate($get(pCommandInfo("parameters","name"),"*"),$char(34))
if (name'["*") {
try {
set $namespace = name
if '..IsIPMEnabled(name) {
write $$$FormattedLine($$$Red,"IPM is not enabled in the "_name_" namespace.")
} else {
set $namespace = name
}
} catch ex {
$$$ThrowStatus($$$ERROR($$$GeneralError,"Failed to switch to namespace: " _ name))
}
Expand All @@ -1099,9 +1103,17 @@ ClassMethod Namespace(ByRef pCommandInfo) [ Internal ]
do ##class(%Library.Prompt).GetString(prompt, .value)
quit:value=""
try {
set $namespace = $select($data(list(value), ns): $listget(ns), 1: value)
set selectedNamespace = $select($data(list(value), ns): $listget(ns), 1: value)
if '..IsIPMEnabled(selectedNamespace) {
write $$$FormattedLine($$$Red," IPM is not enabled for the selected "_selectedNamespace_" namespace.")
hang 0.5
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of the hang? Its generally not great practice to have hangs (exceptions are for polling purposes)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @isc-kiyer
The purpose of the hang is to ensure the error message is visible to the user. Without the hang, the message IPM is not enabled in this namespace disappears immediately. Adding a 0.5-second hang allows the message to be displayed long enough for the user to notice and read it.

// Clear the current line and move the cursor up to remove the error message
write $$$ClearLineAndMoveUp
continue
}
set $namespace = selectedNamespace
} catch e {
write $char(13),*27,"[K",*27,"[A"
write $$$ClearLineAndMoveUp
continue
}
quit
Expand Down Expand Up @@ -3845,7 +3857,8 @@ ClassMethod DisplayModules(
if pNumbered {
write $justify(i, numbersWidth - 2), ". "
}
write $$$FormattedLinePadRight($$$Magenta, tNS _ "> ", nsWidth)
set ipmStatus=$select('..IsIPMEnabled(tNS):"(IPM not enabled)",1:"")
write $$$FormattedLinePadRight($$$Magenta, tNS _ "> "_ipmStatus, nsWidth)
set tPrefix = $justify("", numbersWidth) _ tNS
kill tModulesList
merge tModulesList = pList(i, "modules")
Expand Down Expand Up @@ -3924,6 +3937,13 @@ ClassMethod DisplayModules(
}
}

ClassMethod IsIPMEnabled(pNamespace As %String = {$namespace}) As %Boolean
{
new $namespace
set $namespace = pNamespace
return $system.CLS.IsMthd("%IPM.Main", "Shell")
}

ClassMethod GetUpstreamPackageVersions(Output list)
{
set query = "SELECT %DLIST(Name) AS Repos FROM %IPM_Repo.Definition"
Expand Down
1 change: 1 addition & 0 deletions src/inc/IPM/Formatting.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ROUTINE %IPM.Formatting [Type=INC]

/// Creates the control sequence for the formatting based on the code
#define ControlSequence(%code) $Char(27)_"["_%code_"m"
#define ClearLineAndMoveUp $char(13),*27,"[K",*27,"[A"

#; Codes to add to convert format types
#define Reset 20
Expand Down