Skip to content

Commit 09cad38

Browse files
Add IsStdioMode property and update plugin URL validation logic. Closes #1519 (#1523)
Co-authored-by: Garry Trinder <garry@trinder365.co.uk>
1 parent db90979 commit 09cad38

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

DevProxy/Commands/DevProxyConfigOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public string? ConfigFile
2121
public int? ApiPort => _parseResult?.GetValueOrDefault<int?>(DevProxyCommand.ApiPortOptionName);
2222
public bool Discover => _parseResult?.GetValueOrDefault<bool?>(DevProxyCommand.DiscoverOptionName) ?? false;
2323
public string? IPAddress => _parseResult?.GetValueOrDefault<string?>(DevProxyCommand.IpAddressOptionName);
24+
public bool IsStdioMode => _parseResult?.CommandResult.Command.Name == "stdio";
2425
public LogFor? LogFor => _parseResult?.GetValueOrDefault<LogFor?>(DevProxyCommand.LogForOptionName);
2526
public LogLevel? LogLevel => _parseResult?.GetValueOrDefault<LogLevel?>(DevProxyCommand.LogLevelOptionName);
2627

DevProxy/Plugins/PluginServiceExtensions.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ public static IServiceCollection AddPlugins(
125125
assembly,
126126
configuration,
127127
services,
128-
logger);
128+
logger,
129+
options.IsStdioMode);
129130
}
130131
catch (Exception ex)
131132
{
@@ -149,14 +150,9 @@ private static void RegisterPlugin(
149150
Assembly assembly,
150151
IConfiguration configuration,
151152
IServiceCollection services,
152-
ILogger logger)
153+
ILogger logger,
154+
bool isStdioMode)
153155
{
154-
if (urlsToWatch.Count == 0)
155-
{
156-
logger.LogError("Plugin {PluginName} must have at least one URL to watch. Please add a URL to watch in the configuration file or use the --urls-to-watch option.", pluginRef.Name);
157-
return;
158-
}
159-
160156
var pluginType = assembly.GetTypes()
161157
.FirstOrDefault(t => t.Name == pluginRef.Name && typeof(IPlugin).IsAssignableFrom(t));
162158
if (pluginType is null)
@@ -165,6 +161,14 @@ private static void RegisterPlugin(
165161
return;
166162
}
167163

164+
// In stdio mode, plugins don't need URLs to watch because they
165+
// communicate through STDIO (JSON-RPC) rather than HTTP
166+
if (urlsToWatch.Count == 0 && !isStdioMode)
167+
{
168+
logger.LogError("Plugin {PluginName} must have at least one URL to watch. Please add a URL to watch in the configuration file or use the --urls-to-watch option.", pluginRef.Name);
169+
return;
170+
}
171+
168172
var isConfigurable = IsConfigurablePlugin(pluginType, out var configType);
169173

170174
if (!isConfigurable || configType is null)

0 commit comments

Comments
 (0)