@@ -43,6 +43,7 @@ sealed class DevProxyCommand : RootCommand
4343 internal const string OutputOptionName = "--output" ;
4444 internal const string DetachedOptionName = "--detach" ;
4545 internal const string InternalDaemonOptionName = "--_internal-daemon" ;
46+ internal const string NoColorOptionName = "--no-color" ;
4647
4748 private static readonly string [ ] globalOptions = [ "--version" ] ;
4849 private static readonly string [ ] helpOptions = [ "--help" , "-h" , "/h" , "-?" , "/?" ] ;
@@ -56,6 +57,7 @@ sealed class DevProxyCommand : RootCommand
5657 private static bool _isInternalDaemonResolved ;
5758 private static bool _stdioLogFilePathResolved ;
5859 private static bool _detachedLogFilePathResolved ;
60+ private static bool _noColorResolved ;
5961
6062 public static bool HasGlobalOptions
6163 {
@@ -214,6 +216,24 @@ public static string DetachedLogFilePath
214216 }
215217 }
216218
219+ public static bool NoColor
220+ {
221+ get
222+ {
223+ if ( _noColorResolved )
224+ {
225+ return field ;
226+ }
227+
228+ var args = Environment . GetCommandLineArgs ( ) ;
229+ field = args . Contains ( NoColorOptionName ) ||
230+ Environment . GetEnvironmentVariable ( "NO_COLOR" ) is not null ||
231+ string . Equals ( Environment . GetEnvironmentVariable ( "TERM" ) , "dumb" , StringComparison . OrdinalIgnoreCase ) ;
232+ _noColorResolved = true ;
233+ return field ;
234+ }
235+ }
236+
217237 public DevProxyCommand (
218238 IEnumerable < IPlugin > plugins ,
219239 ISet < UrlToWatch > urlsToWatch ,
@@ -522,6 +542,13 @@ private void ConfigureCommand()
522542 Hidden = true
523543 } ;
524544
545+ var noColorOption = new Option < bool > ( NoColorOptionName )
546+ {
547+ Description = "Disable colored output" ,
548+ Arity = ArgumentArity . Zero ,
549+ Recursive = true
550+ } ;
551+
525552 var options = new List < Option >
526553 {
527554 apiPortOption ,
@@ -534,6 +561,7 @@ private void ConfigureCommand()
534561 internalDaemonOption ,
535562 ipAddressOption ,
536563 logLevelOption ,
564+ noColorOption ,
537565 noFirstRunOption ,
538566 noWatchOption ,
539567 outputOption ,
0 commit comments