Bläddra i källkod

Testing color and ANSI output

Lukas Angerer 4 år sedan
förälder
incheckning
8eb5859e66
2 ändrade filer med 18 tillägg och 1 borttagningar
  1. 2 1
      CustomHostingDemo/CustomHostingDemo.csproj
  2. 16 0
      CustomHostingDemo/HelloCommand.cs

+ 2 - 1
CustomHostingDemo/CustomHostingDemo.csproj

@@ -9,7 +9,8 @@
     <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
     <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
     <PackageReference Include="Ninject" Version="3.3.4" />
-    <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20071.2" />
+    <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" />
+    <PackageReference Include="System.CommandLine.Rendering" Version="0.3.0-alpha.21216.1" />
   </ItemGroup>
 
   <ItemGroup>

+ 16 - 0
CustomHostingDemo/HelloCommand.cs

@@ -40,6 +40,22 @@ namespace CustomHostingDemo
 
                 _logger.LogInformation("INFO from DefaultHandler");
 
+                var span = new ContainerSpan(StyleSpan.UnderlinedOn(),
+                              new ContentSpan("Underlining"),
+                              StyleSpan.UnderlinedOff());
+
+                context.Console.Out.WriteLine(span.ToString(OutputMode.Auto));
+
+                context.Console.Out.WriteLine(new ContainerSpan(
+                    ForegroundColorSpan.LightGreen(),
+                    StyleSpan.BlinkOn(),
+                    new ContentSpan("Blinking"),
+                    StyleSpan.BlinkOff(),
+                    new ContentSpan("Noblink"),
+                    ForegroundColorSpan.Reset(),
+                    new ContentSpan("Normal")
+                ).ToString(OutputMode.Ansi));
+
                 return Task.FromResult(3);
             }
         }