Skip to content

Commit 10e5863

Browse files
Copilotwaldekmastykarzgarrytrinder
authored
Add --no-watch flag to disable config file auto-restart (#1554)
* Initial plan * Add --no-watch flag to disable config file auto-restart Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com> Co-authored-by: Waldek Mastykarz <waldek@mastykarz.nl> Co-authored-by: Garry Trinder <garry@trinder365.co.uk>
1 parent 85ccd72 commit 10e5863

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

DevProxy.Abstractions/Proxy/IProxyConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public interface IProxyConfiguration
4141
LogLevel LogLevel { get; }
4242
ReleaseType NewVersionNotification { get; }
4343
bool NoFirstRun { get; set; }
44+
bool NoWatch { get; set; }
4445
int Port { get; set; }
4546
bool Record { get; set; }
4647
bool ShowTimestamps { get; }

DevProxy/Commands/DevProxyCommand.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ sealed class DevProxyCommand : RootCommand
3333
Description = "The path to the configuration file"
3434
};
3535
internal const string NoFirstRunOptionName = "--no-first-run";
36+
internal const string NoWatchOptionName = "--no-watch";
3637
internal const string AsSystemProxyOptionName = "--as-system-proxy";
3738
internal const string InstallCertOptionName = "--install-cert";
3839
internal const string UrlsToWatchOptionName = "--urls-to-watch";
@@ -402,6 +403,11 @@ private void ConfigureCommand()
402403
Description = "Skip the first run experience"
403404
};
404405

406+
var noWatchOption = new Option<bool?>(NoWatchOptionName)
407+
{
408+
Description = "Disable automatic restart on configuration file changes"
409+
};
410+
405411
var discoverOption = new Option<bool?>(DiscoverOptionName)
406412
{
407413
Description = "Run Dev Proxy in discovery mode"
@@ -529,6 +535,7 @@ private void ConfigureCommand()
529535
ipAddressOption,
530536
logLevelOption,
531537
noFirstRunOption,
538+
noWatchOption,
532539
outputOption,
533540
portOption,
534541
recordOption,
@@ -613,6 +620,11 @@ private void ConfigureFromOptions(ParseResult parseResult)
613620
{
614621
_proxyConfiguration.NoFirstRun = noFirstRun.Value;
615622
}
623+
var noWatch = parseResult.GetValueOrDefault<bool?>(NoWatchOptionName);
624+
if (noWatch is not null)
625+
{
626+
_proxyConfiguration.NoWatch = noWatch.Value;
627+
}
616628
var asSystemProxy = parseResult.GetValueOrDefault<bool?>(AsSystemProxyOptionName);
617629
if (asSystemProxy is not null)
618630
{

DevProxy/Proxy/ConfigFileWatcher.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ public static void Reset()
4444

4545
public Task StartAsync(CancellationToken cancellationToken)
4646
{
47+
if (_proxyConfiguration.NoWatch)
48+
{
49+
_logger.LogDebug("Configuration file watching is disabled");
50+
return Task.CompletedTask;
51+
}
52+
4753
var configFilePath = _proxyConfiguration.ConfigFile;
4854
if (string.IsNullOrEmpty(configFilePath) || !File.Exists(configFilePath))
4955
{

DevProxy/Proxy/ProxyConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public string ConfigFile
3838
[JsonConverter(typeof(JsonStringEnumConverter))]
3939
public LogLevel LogLevel { get; set; } = LogLevel.Information;
4040
public bool NoFirstRun { get; set; }
41+
public bool NoWatch { get; set; }
4142
[JsonConverter(typeof(JsonStringEnumConverter))]
4243
public ReleaseType NewVersionNotification { get; set; } = ReleaseType.Stable;
4344
public int Port { get; set; } = 8000;

0 commit comments

Comments
 (0)