Skip to content

Commit 8c8d0b0

Browse files
Address review feedback: add CI env var check and return non-zero exit code
- CertCommand and ProxyEngine: check both Console.IsInputRedirected and CI env var for non-interactive detection, matching ExecuteAsync pattern - RemoveCert returns int: exit code 1 for non-interactive failure or exceptions, 0 for success Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
1 parent 005df23 commit 8c8d0b0

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

DevProxy/Commands/CertCommand.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private async Task EnsureCertAsync()
7474
_logger.LogTrace("EnsureCertAsync() finished");
7575
}
7676

77-
public void RemoveCert(ParseResult parseResult)
77+
public int RemoveCert(ParseResult parseResult)
7878
{
7979
_logger.LogTrace("RemoveCert() called");
8080

@@ -83,16 +83,17 @@ public void RemoveCert(ParseResult parseResult)
8383
var isForced = parseResult.GetValue(_forceOption);
8484
if (!isForced)
8585
{
86-
if (Console.IsInputRedirected)
86+
if (Console.IsInputRedirected ||
87+
Environment.GetEnvironmentVariable("CI") is not null)
8788
{
8889
_logger.LogError("Confirmation required but running in non-interactive mode. Use --force to skip confirmation.");
89-
return;
90+
return 1;
9091
}
9192

9293
var isConfirmed = PromptConfirmation("Do you want to remove the root certificate", acceptByDefault: false);
9394
if (!isConfirmed)
9495
{
95-
return;
96+
return 0;
9697
}
9798
}
9899

@@ -117,10 +118,12 @@ public void RemoveCert(ParseResult parseResult)
117118
}
118119

119120
_logger.LogInformation("DONE");
121+
return 0;
120122
}
121123
catch (Exception ex)
122124
{
123125
_logger.LogError(ex, "Error removing certificate");
126+
return 1;
124127
}
125128
finally
126129
{

DevProxy/Proxy/ProxyEngine.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ private void FirstRunSetup()
233233
Console.WriteLine("Dev Proxy uses a self-signed certificate to intercept and inspect HTTPS traffic.");
234234

235235
string? answer;
236-
if (Console.IsInputRedirected)
236+
if (Console.IsInputRedirected ||
237+
Environment.GetEnvironmentVariable("CI") is not null)
237238
{
238239
// Non-interactive mode, default to trusting the certificate
239240
_logger.LogInformation("Non-interactive mode detected. Defaulting to trusting the certificate.");

0 commit comments

Comments
 (0)