Skip to content

Commit 404728c

Browse files
committed
feat: refactor portal info command to improve configuration handling and response messages
1 parent c050bb4 commit 404728c

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

src/PepperDash.Essentials/ControlSystem.cs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,8 @@ private void StartSystem(object preventInitialization)
130130
(ConfigReader.ConfigObject, Newtonsoft.Json.Formatting.Indented).Replace(Environment.NewLine, "\r\n"));
131131
}, "showconfig", "Shows the current running merged config", ConsoleAccessLevelEnum.AccessOperator);
132132

133-
CrestronConsole.AddNewConsoleCommand(s =>
134-
CrestronConsole.ConsoleCommandResponse(
135-
"This system can be found at the following URLs:{2}" +
136-
"System URL: {0}{2}" +
137-
"Template URL: {1}{2}",
138-
ConfigReader.ConfigObject.SystemUrl,
139-
ConfigReader.ConfigObject.TemplateUrl,
140-
CrestronEnvironment.NewLine),
133+
CrestronConsole.AddNewConsoleCommand(
134+
PrintPortalInfo,
141135
"portalinfo",
142136
"Shows portal URLS from configuration",
143137
ConsoleAccessLevelEnum.AccessOperator);
@@ -160,6 +154,29 @@ private void StartSystem(object preventInitialization)
160154
}
161155
}
162156

157+
private void PrintPortalInfo(string args)
158+
{
159+
if(ConfigReader.ConfigObject == null)
160+
{
161+
CrestronConsole.ConsoleCommandResponse("No configuration loaded. Cannot show portal URLs.");
162+
return;
163+
}
164+
165+
if (string.IsNullOrEmpty(ConfigReader.ConfigObject.SystemUrl) && string.IsNullOrEmpty(ConfigReader.ConfigObject.TemplateUrl))
166+
{
167+
CrestronConsole.ConsoleCommandResponse("No portal URLs defined in config.");
168+
return;
169+
}
170+
171+
CrestronConsole.ConsoleCommandResponse(
172+
"This system can be found at the following URLs:{2}" +
173+
"System URL: {0}{2}" +
174+
"Template URL: {1}{2}",
175+
ConfigReader.ConfigObject?.SystemUrl,
176+
ConfigReader.ConfigObject?.TemplateUrl,
177+
CrestronEnvironment.NewLine);
178+
}
179+
163180
/// <summary>
164181
/// DeterminePlatform method
165182
/// </summary>
@@ -257,11 +274,6 @@ public void GoWithLoad()
257274
PluginLoader.AddProgramAssemblies();
258275

259276
_ = new Core.DeviceFactory();
260-
// _ = new Devices.Common.DeviceFactory();
261-
// _ = new DeviceFactory();
262-
263-
// _ = new ProcessorExtensionDeviceFactory();
264-
// _ = new MobileControlFactory();
265277

266278
LoadAssets(Global.ApplicationDirectoryPathPrefix, Global.FilePathPrefix);
267279

0 commit comments

Comments
 (0)