mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 08:52:50 +08:00
Use file scoped namespace declarations
This commit is contained in:
parent
1dbaf50935
commit
ec1188b837
@ -30,6 +30,9 @@ trim_trailing_whitespace = false
|
|||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
|
|
||||||
[*.cs]
|
[*.cs]
|
||||||
|
# Prefer file scoped namespace declarations
|
||||||
|
csharp_style_namespace_declarations = file_scoped:warning
|
||||||
|
|
||||||
# Sort using and Import directives with System.* appearing first
|
# Sort using and Import directives with System.* appearing first
|
||||||
dotnet_sort_system_directives_first = true
|
dotnet_sort_system_directives_first = true
|
||||||
dotnet_separate_import_directive_groups = false
|
dotnet_separate_import_directive_groups = false
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static partial class Program
|
||||||
{
|
{
|
||||||
public static partial class Program
|
|
||||||
{
|
|
||||||
public sealed class BarSettings : CommandSettings
|
public sealed class BarSettings : CommandSettings
|
||||||
{
|
{
|
||||||
[CommandOption("--count")]
|
[CommandOption("--count")]
|
||||||
@ -12,5 +12,4 @@ namespace Spectre.Console.Examples
|
|||||||
[DefaultValue(1)]
|
[DefaultValue(1)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static partial class Program
|
||||||
{
|
{
|
||||||
public static partial class Program
|
|
||||||
{
|
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
var app = new CommandApp();
|
var app = new CommandApp();
|
||||||
@ -34,5 +34,4 @@ namespace Spectre.Console.Examples
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@ using System.ComponentModel;
|
|||||||
using Demo.Utilities;
|
using Demo.Utilities;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Demo.Commands
|
namespace Demo.Commands;
|
||||||
|
|
||||||
|
[Description("Add a NuGet package reference to the project.")]
|
||||||
|
public sealed class AddPackageCommand : Command<AddPackageCommand.Settings>
|
||||||
{
|
{
|
||||||
[Description("Add a NuGet package reference to the project.")]
|
|
||||||
public sealed class AddPackageCommand : Command<AddPackageCommand.Settings>
|
|
||||||
{
|
|
||||||
public sealed class Settings : AddSettings
|
public sealed class Settings : AddSettings
|
||||||
{
|
{
|
||||||
[CommandArgument(0, "<PACKAGENAME>")]
|
[CommandArgument(0, "<PACKAGENAME>")]
|
||||||
@ -43,5 +43,4 @@ namespace Demo.Commands
|
|||||||
SettingsDumper.Dump(settings);
|
SettingsDumper.Dump(settings);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ using System.ComponentModel;
|
|||||||
using Demo.Utilities;
|
using Demo.Utilities;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Demo.Commands
|
namespace Demo.Commands;
|
||||||
|
|
||||||
|
public sealed class AddReferenceCommand : Command<AddReferenceCommand.Settings>
|
||||||
{
|
{
|
||||||
public sealed class AddReferenceCommand : Command<AddReferenceCommand.Settings>
|
|
||||||
{
|
|
||||||
public sealed class Settings : AddSettings
|
public sealed class Settings : AddSettings
|
||||||
{
|
{
|
||||||
[CommandArgument(0, "<PROJECTPATH>")]
|
[CommandArgument(0, "<PROJECTPATH>")]
|
||||||
@ -26,5 +26,4 @@ namespace Demo.Commands
|
|||||||
SettingsDumper.Dump(settings);
|
SettingsDumper.Dump(settings);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Demo.Commands
|
namespace Demo.Commands;
|
||||||
|
|
||||||
|
public abstract class AddSettings : CommandSettings
|
||||||
{
|
{
|
||||||
public abstract class AddSettings : CommandSettings
|
|
||||||
{
|
|
||||||
[CommandArgument(0, "<PROJECT>")]
|
[CommandArgument(0, "<PROJECT>")]
|
||||||
[Description("The project file to operate on. If a file is not specified, the command will search the current directory for one.")]
|
[Description("The project file to operate on. If a file is not specified, the command will search the current directory for one.")]
|
||||||
public string Project { get; set; }
|
public string Project { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@ using System.ComponentModel;
|
|||||||
using Demo.Utilities;
|
using Demo.Utilities;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Demo.Commands
|
namespace Demo.Commands;
|
||||||
|
|
||||||
|
[Description("Build and run a .NET project output.")]
|
||||||
|
public sealed class RunCommand : Command<RunCommand.Settings>
|
||||||
{
|
{
|
||||||
[Description("Build and run a .NET project output.")]
|
|
||||||
public sealed class RunCommand : Command<RunCommand.Settings>
|
|
||||||
{
|
|
||||||
public sealed class Settings : CommandSettings
|
public sealed class Settings : CommandSettings
|
||||||
{
|
{
|
||||||
[CommandOption("-c|--configuration <CONFIGURATION>")]
|
[CommandOption("-c|--configuration <CONFIGURATION>")]
|
||||||
@ -66,5 +66,4 @@ namespace Demo.Commands
|
|||||||
SettingsDumper.Dump(settings);
|
SettingsDumper.Dump(settings);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,11 @@ using System.ComponentModel;
|
|||||||
using Demo.Utilities;
|
using Demo.Utilities;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Demo.Commands
|
namespace Demo.Commands;
|
||||||
|
|
||||||
|
[Description("Launches a web server in the current working directory and serves all files in it.")]
|
||||||
|
public sealed class ServeCommand : Command<ServeCommand.Settings>
|
||||||
{
|
{
|
||||||
[Description("Launches a web server in the current working directory and serves all files in it.")]
|
|
||||||
public sealed class ServeCommand : Command<ServeCommand.Settings>
|
|
||||||
{
|
|
||||||
public sealed class Settings : CommandSettings
|
public sealed class Settings : CommandSettings
|
||||||
{
|
{
|
||||||
[CommandOption("-p|--port <PORT>")]
|
[CommandOption("-p|--port <PORT>")]
|
||||||
@ -37,5 +37,4 @@ namespace Demo.Commands
|
|||||||
SettingsDumper.Dump(settings);
|
SettingsDumper.Dump(settings);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using Demo.Commands;
|
using Demo.Commands;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Demo
|
namespace Demo;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
var app = new CommandApp();
|
var app = new CommandApp();
|
||||||
@ -33,5 +33,4 @@ namespace Demo
|
|||||||
|
|
||||||
return app.Run(args);
|
return app.Run(args);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Demo.Utilities
|
namespace Demo.Utilities;
|
||||||
|
|
||||||
|
public static class SettingsDumper
|
||||||
{
|
{
|
||||||
public static class SettingsDumper
|
|
||||||
{
|
|
||||||
public static void Dump(CommandSettings settings)
|
public static void Dump(CommandSettings settings)
|
||||||
{
|
{
|
||||||
var table = new Table().RoundedBorder();
|
var table = new Table().RoundedBorder();
|
||||||
@ -25,5 +25,4 @@ namespace Demo.Utilities
|
|||||||
|
|
||||||
AnsiConsole.Write(table);
|
AnsiConsole.Write(table);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,19 +3,19 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Demo
|
namespace Demo;
|
||||||
|
|
||||||
|
public enum Verbosity
|
||||||
{
|
{
|
||||||
public enum Verbosity
|
|
||||||
{
|
|
||||||
Quiet,
|
Quiet,
|
||||||
Minimal,
|
Minimal,
|
||||||
Normal,
|
Normal,
|
||||||
Detailed,
|
Detailed,
|
||||||
Diagnostic
|
Diagnostic
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class VerbosityConverter : TypeConverter
|
public sealed class VerbosityConverter : TypeConverter
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, Verbosity> _lookup;
|
private readonly Dictionary<string, Verbosity> _lookup;
|
||||||
|
|
||||||
public VerbosityConverter()
|
public VerbosityConverter()
|
||||||
@ -50,5 +50,4 @@ namespace Demo
|
|||||||
}
|
}
|
||||||
throw new NotSupportedException("Can't convert value to verbosity.");
|
throw new NotSupportedException("Can't convert value to verbosity.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public sealed class MyCommand : Command
|
||||||
{
|
{
|
||||||
public sealed class MyCommand : Command
|
|
||||||
{
|
|
||||||
public override int Execute(CommandContext context)
|
public override int Execute(CommandContext context)
|
||||||
{
|
{
|
||||||
if (!(context.Data is int data))
|
if (!(context.Data is int data))
|
||||||
@ -16,5 +16,4 @@ namespace Spectre.Console.Examples
|
|||||||
AnsiConsole.WriteLine("Value = {0}", data);
|
AnsiConsole.WriteLine("Value = {0}", data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
var app = new CommandApp();
|
var app = new CommandApp();
|
||||||
app.Configure(config =>
|
app.Configure(config =>
|
||||||
{
|
{
|
||||||
foreach(var index in Enumerable.Range(1, 10))
|
foreach (var index in Enumerable.Range(1, 10))
|
||||||
{
|
{
|
||||||
config.AddCommand<MyCommand>($"c{index}")
|
config.AddCommand<MyCommand>($"c{index}")
|
||||||
.WithDescription($"Prints the number {index}")
|
.WithDescription($"Prints the number {index}")
|
||||||
@ -20,5 +20,4 @@ namespace Spectre.Console.Examples
|
|||||||
|
|
||||||
return app.Run(args);
|
return app.Run(args);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ using System;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public sealed class DefaultCommand : Command<DefaultCommand.Settings>
|
||||||
{
|
{
|
||||||
public sealed class DefaultCommand : Command<DefaultCommand.Settings>
|
|
||||||
{
|
|
||||||
private readonly IGreeter _greeter;
|
private readonly IGreeter _greeter;
|
||||||
|
|
||||||
public sealed class Settings : CommandSettings
|
public sealed class Settings : CommandSettings
|
||||||
@ -26,5 +26,4 @@ namespace Spectre.Console.Examples
|
|||||||
_greeter.Greet(settings.Name);
|
_greeter.Greet(settings.Name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
{
|
|
||||||
public interface IGreeter
|
|
||||||
{
|
|
||||||
void Greet(string name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class HelloWorldGreeter : IGreeter
|
public interface IGreeter
|
||||||
{
|
{
|
||||||
|
void Greet(string name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class HelloWorldGreeter : IGreeter
|
||||||
|
{
|
||||||
public void Greet(string name)
|
public void Greet(string name)
|
||||||
{
|
{
|
||||||
AnsiConsole.WriteLine($"Hello {name}!");
|
AnsiConsole.WriteLine($"Hello {name}!");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ using System;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public sealed class TypeRegistrar : ITypeRegistrar
|
||||||
{
|
{
|
||||||
public sealed class TypeRegistrar : ITypeRegistrar
|
|
||||||
{
|
|
||||||
private readonly IServiceCollection _builder;
|
private readonly IServiceCollection _builder;
|
||||||
|
|
||||||
public TypeRegistrar(IServiceCollection builder)
|
public TypeRegistrar(IServiceCollection builder)
|
||||||
@ -37,5 +37,4 @@ namespace Spectre.Console.Examples
|
|||||||
|
|
||||||
_builder.AddSingleton(service, (provider) => func());
|
_builder.AddSingleton(service, (provider) => func());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ using System;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public sealed class TypeResolver : ITypeResolver, IDisposable
|
||||||
{
|
{
|
||||||
public sealed class TypeResolver : ITypeResolver, IDisposable
|
|
||||||
{
|
|
||||||
private readonly IServiceProvider _provider;
|
private readonly IServiceProvider _provider;
|
||||||
|
|
||||||
public TypeResolver(IServiceProvider provider)
|
public TypeResolver(IServiceProvider provider)
|
||||||
@ -30,5 +30,4 @@ namespace Spectre.Console.Examples
|
|||||||
disposable.Dispose();
|
disposable.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public class Program
|
||||||
{
|
{
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
// Create a type registrar and register any dependencies.
|
// Create a type registrar and register any dependencies.
|
||||||
@ -18,5 +18,4 @@ namespace Spectre.Console.Examples
|
|||||||
var app = new CommandApp<DefaultCommand>(registrar);
|
var app = new CommandApp<DefaultCommand>(registrar);
|
||||||
return app.Run(args);
|
return app.Run(args);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public class HelloCommand : Command<HelloCommand.Settings>
|
||||||
{
|
{
|
||||||
public class HelloCommand : Command<HelloCommand.Settings>
|
|
||||||
{
|
|
||||||
private ILogger<HelloCommand> _logger;
|
private ILogger<HelloCommand> _logger;
|
||||||
private IAnsiConsole _console;
|
private IAnsiConsole _console;
|
||||||
|
|
||||||
@ -30,5 +30,4 @@ namespace Spectre.Console.Examples
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -5,10 +5,10 @@ using System.Globalization;
|
|||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public class LogCommandSettings : CommandSettings
|
||||||
{
|
{
|
||||||
public class LogCommandSettings : CommandSettings
|
|
||||||
{
|
|
||||||
[CommandOption("--logFile")]
|
[CommandOption("--logFile")]
|
||||||
[Description("Path and file name for logging")]
|
[Description("Path and file name for logging")]
|
||||||
public string LogFile { get; set; }
|
public string LogFile { get; set; }
|
||||||
@ -18,10 +18,10 @@ namespace Spectre.Console.Examples
|
|||||||
[TypeConverter(typeof(VerbosityConverter))]
|
[TypeConverter(typeof(VerbosityConverter))]
|
||||||
[DefaultValue(LogEventLevel.Information)]
|
[DefaultValue(LogEventLevel.Information)]
|
||||||
public LogEventLevel LogLevel { get; set; }
|
public LogEventLevel LogLevel { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class VerbosityConverter : TypeConverter
|
public sealed class VerbosityConverter : TypeConverter
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, LogEventLevel> _lookup;
|
private readonly Dictionary<string, LogEventLevel> _lookup;
|
||||||
|
|
||||||
public VerbosityConverter()
|
public VerbosityConverter()
|
||||||
@ -52,5 +52,4 @@ namespace Spectre.Console.Examples
|
|||||||
}
|
}
|
||||||
throw new NotSupportedException("Can't convert value to verbosity.");
|
throw new NotSupportedException("Can't convert value to verbosity.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
using Serilog.Core;
|
using Serilog.Core;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public class LogInterceptor : ICommandInterceptor
|
||||||
{
|
{
|
||||||
public class LogInterceptor : ICommandInterceptor
|
|
||||||
{
|
|
||||||
public static readonly LoggingLevelSwitch LogLevel = new();
|
public static readonly LoggingLevelSwitch LogLevel = new();
|
||||||
|
|
||||||
public void Intercept(CommandContext context, CommandSettings settings)
|
public void Intercept(CommandContext context, CommandSettings settings)
|
||||||
@ -15,5 +15,4 @@ namespace Spectre.Console.Examples
|
|||||||
LogLevel.MinimumLevel = logSettings.LogLevel;
|
LogLevel.MinimumLevel = logSettings.LogLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
using Serilog.Core;
|
using Serilog.Core;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
internal class LoggingEnricher : ILogEventEnricher
|
||||||
{
|
{
|
||||||
internal class LoggingEnricher : ILogEventEnricher
|
|
||||||
{
|
|
||||||
private string _cachedLogFilePath;
|
private string _cachedLogFilePath;
|
||||||
private LogEventProperty _cachedLogFilePathProperty;
|
private LogEventProperty _cachedLogFilePathProperty;
|
||||||
|
|
||||||
@ -34,5 +34,4 @@ namespace Spectre.Console.Examples
|
|||||||
|
|
||||||
logEvent.AddPropertyIfAbsent(logFilePathProperty);
|
logEvent.AddPropertyIfAbsent(logFilePathProperty);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,10 +2,10 @@ using System;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public sealed class TypeRegistrar : ITypeRegistrar
|
||||||
{
|
{
|
||||||
public sealed class TypeRegistrar : ITypeRegistrar
|
|
||||||
{
|
|
||||||
private readonly IServiceCollection _builder;
|
private readonly IServiceCollection _builder;
|
||||||
|
|
||||||
public TypeRegistrar(IServiceCollection builder)
|
public TypeRegistrar(IServiceCollection builder)
|
||||||
@ -37,5 +37,4 @@ namespace Spectre.Console.Examples
|
|||||||
|
|
||||||
_builder.AddSingleton(service, _ => func());
|
_builder.AddSingleton(service, _ => func());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,10 +2,10 @@ using System;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public sealed class TypeResolver : ITypeResolver
|
||||||
{
|
{
|
||||||
public sealed class TypeResolver : ITypeResolver
|
|
||||||
{
|
|
||||||
private readonly IServiceProvider _provider;
|
private readonly IServiceProvider _provider;
|
||||||
|
|
||||||
public TypeResolver(IServiceProvider provider)
|
public TypeResolver(IServiceProvider provider)
|
||||||
@ -17,5 +17,4 @@ namespace Spectre.Console.Examples
|
|||||||
{
|
{
|
||||||
return _provider.GetRequiredService(type);
|
return _provider.GetRequiredService(type);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -12,10 +12,10 @@ using Spectre.Console.Cli;
|
|||||||
* Spectre.Console CommandInterceptor
|
* Spectre.Console CommandInterceptor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public class Program
|
||||||
{
|
{
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
static int Main(string[] args)
|
static int Main(string[] args)
|
||||||
{
|
{
|
||||||
// to retrieve the log file name, we must first parse the command settings
|
// to retrieve the log file name, we must first parse the command settings
|
||||||
@ -49,5 +49,4 @@ namespace Spectre.Console.Examples
|
|||||||
|
|
||||||
return app.Run(args);
|
return app.Run(args);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
// Render panel borders
|
// Render panel borders
|
||||||
@ -38,7 +38,7 @@ namespace Spectre.Console.Examples
|
|||||||
AnsiConsole.Write(
|
AnsiConsole.Write(
|
||||||
new Padder(
|
new Padder(
|
||||||
new Columns(items).PadRight(2),
|
new Columns(items).PadRight(2),
|
||||||
new Padding(2,0,0,0)));
|
new Padding(2, 0, 0, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TableBorders()
|
private static void TableBorders()
|
||||||
@ -86,5 +86,4 @@ namespace Spectre.Console.Examples
|
|||||||
AnsiConsole.Write(new Rule($"[white bold]{title}[/]").RuleStyle("grey").LeftAligned());
|
AnsiConsole.Write(new Rule($"[white bold]{title}[/]").RuleStyle("grey").LeftAligned());
|
||||||
AnsiConsole.WriteLine();
|
AnsiConsole.WriteLine();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
AnsiConsole.WriteLine();
|
AnsiConsole.WriteLine();
|
||||||
@ -13,5 +13,4 @@ namespace Spectre.Console.Examples
|
|||||||
.AddCalendarEvent("Another event", 2020, 10, 2)
|
.AddCalendarEvent("Another event", 2020, 10, 2)
|
||||||
.AddCalendarEvent("A third event", 2020, 10, 13));
|
.AddCalendarEvent("A third event", 2020, 10, 13));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ Licensed under GNU Free Documentation License 1.2
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Mandelbrot
|
||||||
{
|
{
|
||||||
public static class Mandelbrot
|
|
||||||
{
|
|
||||||
private const double MaxValueExtent = 2.0;
|
private const double MaxValueExtent = 2.0;
|
||||||
|
|
||||||
private struct ComplexNumber
|
private struct ComplexNumber
|
||||||
@ -82,5 +82,4 @@ namespace Spectre.Console.Examples
|
|||||||
const double ContrastValue = 0.2;
|
const double ContrastValue = 0.2;
|
||||||
return new Color(0, 0, (byte)(MaxColor * Math.Pow(value, ContrastValue)));
|
return new Color(0, 0, (byte)(MaxColor * Math.Pow(value, ContrastValue)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ using System.Reflection;
|
|||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
// Draw a mandelbrot set using a Canvas
|
// Draw a mandelbrot set using a Canvas
|
||||||
@ -43,5 +43,4 @@ namespace Spectre.Console.Examples
|
|||||||
AnsiConsole.WriteLine();
|
AnsiConsole.WriteLine();
|
||||||
AnsiConsole.Write(canvas);
|
AnsiConsole.Write(canvas);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
// Render a bar chart
|
// Render a bar chart
|
||||||
@ -37,5 +37,4 @@ namespace Spectre.Console.Examples
|
|||||||
.Padding(1, 1)
|
.Padding(1, 1)
|
||||||
.Header(title));
|
.Header(title));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
@ -99,5 +99,4 @@ namespace Spectre.Console.Examples
|
|||||||
AnsiConsole.Write(new ColorBox(width: 80, height: 15));
|
AnsiConsole.Write(new ColorBox(width: 80, height: 15));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
var cards = new List<Panel>();
|
var cards = new List<Panel>();
|
||||||
foreach(var user in User.LoadUsers())
|
foreach (var user in User.LoadUsers())
|
||||||
{
|
{
|
||||||
cards.Add(
|
cards.Add(
|
||||||
new Panel(GetCardContent(user))
|
new Panel(GetCardContent(user))
|
||||||
@ -26,5 +26,4 @@ namespace Spectre.Console.Examples
|
|||||||
|
|
||||||
return $"[b]{name}[/]\n[yellow]{city}[/]";
|
return $"[b]{name}[/]\n[yellow]{city}[/]";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public sealed class User
|
||||||
{
|
{
|
||||||
public sealed class User
|
|
||||||
{
|
|
||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
public string City { get; set; }
|
public string City { get; set; }
|
||||||
@ -85,5 +85,4 @@ namespace Spectre.Console.Examples
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
AnsiConsole.Write("Hello");
|
AnsiConsole.Write("Hello");
|
||||||
@ -14,5 +14,4 @@ namespace Spectre.Console.Examples
|
|||||||
AnsiConsole.Cursor.Move(CursorDirection.Left, 5);
|
AnsiConsole.Cursor.Move(CursorDirection.Left, 5);
|
||||||
AnsiConsole.WriteLine("Universe");
|
AnsiConsole.WriteLine("Universe");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
// Show a known emoji
|
// Show a known emoji
|
||||||
@ -18,5 +18,4 @@ namespace Spectre.Console.Examples
|
|||||||
new Panel("[yellow]Hello :globe_showing_europe_africa:![/]")
|
new Panel("[yellow]Hello :globe_showing_europe_africa:![/]")
|
||||||
.RoundedBorder());
|
.RoundedBorder());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Security.Authentication;
|
using System.Security.Authentication;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -51,7 +51,7 @@ namespace Spectre.Console.Examples
|
|||||||
{
|
{
|
||||||
CheckCredentials(foo, bar);
|
CheckCredentials(foo, bar);
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Whaaat?", ex);
|
throw new InvalidOperationException("Whaaat?", ex);
|
||||||
}
|
}
|
||||||
@ -61,5 +61,4 @@ namespace Spectre.Console.Examples
|
|||||||
{
|
{
|
||||||
throw new InvalidCredentialException("The credentials are invalid.");
|
throw new InvalidCredentialException("The credentials are invalid.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
AnsiConsole.Write(new FigletText("Left aligned").LeftAligned().Color(Color.Red));
|
AnsiConsole.Write(new FigletText("Left aligned").LeftAligned().Color(Color.Red));
|
||||||
AnsiConsole.Write(new FigletText("Centered").Centered().Color(Color.Green));
|
AnsiConsole.Write(new FigletText("Centered").Centered().Color(Color.Green));
|
||||||
AnsiConsole.Write(new FigletText("Right aligned").RightAligned().Color(Color.Blue));
|
AnsiConsole.Write(new FigletText("Right aligned").RightAligned().Color(Color.Blue));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
AnsiConsole.WriteLine();
|
AnsiConsole.WriteLine();
|
||||||
@ -18,5 +18,4 @@ namespace Spectre.Console.Examples
|
|||||||
|
|
||||||
AnsiConsole.Write(grid);
|
AnsiConsole.Write(grid);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
var grid = new Grid()
|
var grid = new Grid()
|
||||||
@ -28,5 +28,4 @@ namespace Spectre.Console.Examples
|
|||||||
{
|
{
|
||||||
return value ? "Yes" : "No";
|
return value ? "Yes" : "No";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
if (AnsiConsole.Profile.Capabilities.Links)
|
if (AnsiConsole.Profile.Capabilities.Links)
|
||||||
@ -15,5 +15,4 @@ namespace Spectre.Console.Examples
|
|||||||
AnsiConsole.MarkupLine("[yellow](╯°□°)╯[/]︵ [blue]┻━┻[/]");
|
AnsiConsole.MarkupLine("[yellow](╯°□°)╯[/]︵ [blue]┻━┻[/]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
var table = new Table().Centered();
|
var table = new Table().Centered();
|
||||||
@ -77,5 +77,4 @@ namespace Spectre.Console.Examples
|
|||||||
Update(400, () => table.Caption("[[ [blue]THE END[/] ]]"));
|
Update(400, () => table.Caption("[[ [blue]THE END[/] ]]"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
private const int NumberOfRows = 10;
|
private const int NumberOfRows = 10;
|
||||||
|
|
||||||
private static readonly Random _random = new();
|
private static readonly Random _random = new();
|
||||||
@ -82,5 +82,4 @@ namespace Spectre.Console.Examples
|
|||||||
|
|
||||||
return (source, dest, rate);
|
return (source, dest, rate);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,3 @@ Write(new Table()
|
|||||||
.AddColumns("[red]Greeting[/]", "[red]Subject[/]")
|
.AddColumns("[red]Greeting[/]", "[red]Subject[/]")
|
||||||
.AddRow("[yellow]Hello[/]", "World")
|
.AddRow("[yellow]Hello[/]", "World")
|
||||||
.AddRow("[green]Oh hi[/]", "[blue u]Mark[/]"));
|
.AddRow("[green]Oh hi[/]", "[blue u]Mark[/]"));
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
var content = new Markup(
|
var content = new Markup(
|
||||||
@ -36,5 +36,4 @@ namespace Spectre.Console.Examples
|
|||||||
.Header("[blue]Right[/]")
|
.Header("[blue]Right[/]")
|
||||||
.HeaderAlignment(Justify.Right));
|
.HeaderAlignment(Justify.Right));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class DescriptionGenerator
|
||||||
{
|
{
|
||||||
public static class DescriptionGenerator
|
|
||||||
{
|
|
||||||
private static readonly string[] _verbs = new[] { "Downloading", "Rerouting", "Retriculating", "Collapsing", "Folding", "Solving", "Colliding", "Measuring" };
|
private static readonly string[] _verbs = new[] { "Downloading", "Rerouting", "Retriculating", "Collapsing", "Folding", "Solving", "Colliding", "Measuring" };
|
||||||
private static readonly string[] _nouns = new[] { "internet", "splines", "space", "capacitators", "quarks", "algorithms", "data structures", "spacetime" };
|
private static readonly string[] _nouns = new[] { "internet", "splines", "space", "capacitators", "quarks", "algorithms", "data structures", "spacetime" };
|
||||||
|
|
||||||
@ -41,5 +41,4 @@ namespace Spectre.Console.Examples
|
|||||||
return _verbs[_random.Next(0, _verbs.Length)]
|
return _verbs[_random.Next(0, _verbs.Length)]
|
||||||
+ " " + _nouns[_random.Next(0, _nouns.Length)];
|
+ " " + _nouns[_random.Next(0, _nouns.Length)];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
AnsiConsole.MarkupLine("[yellow]Initializing warp drive[/]...");
|
AnsiConsole.MarkupLine("[yellow]Initializing warp drive[/]...");
|
||||||
@ -85,5 +85,4 @@ namespace Spectre.Console.Examples
|
|||||||
DescriptionGenerator.Generate() +
|
DescriptionGenerator.Generate() +
|
||||||
"[grey]...[/]");
|
"[grey]...[/]");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
// No title
|
// No title
|
||||||
@ -37,5 +37,4 @@ namespace Spectre.Console.Examples
|
|||||||
AnsiConsole.Write(rule);
|
AnsiConsole.Write(rule);
|
||||||
AnsiConsole.WriteLine();
|
AnsiConsole.WriteLine();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class ExceptionGenerator
|
||||||
{
|
{
|
||||||
public static class ExceptionGenerator
|
|
||||||
{
|
|
||||||
public static Exception GenerateException()
|
public static Exception GenerateException()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -26,5 +26,4 @@ namespace Spectre.Console.Examples
|
|||||||
{
|
{
|
||||||
throw new InvalidOperationException("Something went very wrong!");
|
throw new InvalidOperationException("Something went very wrong!");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static partial class Program
|
||||||
{
|
{
|
||||||
public static partial class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
var table = new Table().HideHeaders().NoBorder();
|
var table = new Table().HideHeaders().NoBorder();
|
||||||
@ -149,5 +149,4 @@ namespace Spectre.Console.Examples
|
|||||||
.AddItem("PowerShell", 13, Color.Red)
|
.AddItem("PowerShell", 13, Color.Red)
|
||||||
.AddItem("Bash", 5, Color.Blue);
|
.AddItem("Bash", 5, Color.Blue);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
AnsiConsole.Status()
|
AnsiConsole.Status()
|
||||||
@ -65,5 +65,4 @@ namespace Spectre.Console.Examples
|
|||||||
{
|
{
|
||||||
AnsiConsole.MarkupLine($"[grey]LOG:[/] {message}[grey]...[/]");
|
AnsiConsole.MarkupLine($"[grey]LOG:[/] {message}[grey]...[/]");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
AnsiConsole.Write(CreateTable());
|
AnsiConsole.Write(CreateTable());
|
||||||
@ -41,5 +41,4 @@ namespace Spectre.Console.Examples
|
|||||||
.AddRow(second, new Text("Whaaat"), new Text("Lol"))
|
.AddRow(second, new Text("Whaaat"), new Text("Lol"))
|
||||||
.AddRow(new Markup("[blue]Hej[/]").Centered(), new Markup("[yellow]Världen![/]"), Text.Empty);
|
.AddRow(new Markup("[blue]Hej[/]").Centered(), new Markup("[yellow]Världen![/]"), Text.Empty);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
AnsiConsole.WriteLine();
|
AnsiConsole.WriteLine();
|
||||||
@ -39,5 +39,4 @@ namespace Spectre.Console.Examples
|
|||||||
// Return the tree
|
// Return the tree
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public sealed class ColorBox : Renderable
|
||||||
{
|
{
|
||||||
public sealed class ColorBox : Renderable
|
|
||||||
{
|
|
||||||
private readonly int _height;
|
private readonly int _height;
|
||||||
private int? _width;
|
private int? _width;
|
||||||
|
|
||||||
@ -120,5 +120,4 @@ namespace Spectre.Console.Examples
|
|||||||
return temp1;
|
return temp1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Examples
|
namespace Spectre.Console.Examples;
|
||||||
|
|
||||||
|
public static class ColorExtensions
|
||||||
{
|
{
|
||||||
public static class ColorExtensions
|
|
||||||
{
|
|
||||||
public static Color GetInvertedColor(this Color color)
|
public static Color GetInvertedColor(this Color color)
|
||||||
{
|
{
|
||||||
return GetLuminance(color) < 140 ? Color.White : Color.Black;
|
return GetLuminance(color) < 140 ? Color.White : Color.Black;
|
||||||
@ -11,5 +11,4 @@ namespace Spectre.Console.Examples
|
|||||||
{
|
{
|
||||||
return (float)((0.2126 * color.R) + (0.7152 * color.G) + (0.0722 * color.B));
|
return (float)((0.2126 * color.R) + (0.7152 * color.G) + (0.0722 * color.B));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup Label="Settings">
|
<PropertyGroup Label="Settings">
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<LangVersion>9.0</LangVersion>
|
<LangVersion>10</LangVersion>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>embedded</DebugType>
|
<DebugType>embedded</DebugType>
|
||||||
<MinVerSkip Condition="'$(Configuration)' == 'Debug'">true</MinVerSkip>
|
<MinVerSkip Condition="'$(Configuration)' == 'Debug'">true</MinVerSkip>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Spectre.Console.Analyzer.Sandbox
|
namespace Spectre.Console.Analyzer.Sandbox;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sample sandbox for testing out analyzers.
|
||||||
|
/// </summary>
|
||||||
|
public static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Sample sandbox for testing out analyzers.
|
|
||||||
/// </summary>
|
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The program's entry point.
|
/// The program's entry point.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -12,5 +12,4 @@ namespace Spectre.Console.Analyzer.Sandbox
|
|||||||
{
|
{
|
||||||
AnsiConsole.WriteLine("Project is set up with a reference to Spectre.Console.Analyzer");
|
AnsiConsole.WriteLine("Project is set up with a reference to Spectre.Console.Analyzer");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|||||||
using Microsoft.CodeAnalysis.Diagnostics;
|
using Microsoft.CodeAnalysis.Diagnostics;
|
||||||
using Microsoft.CodeAnalysis.Operations;
|
using Microsoft.CodeAnalysis.Operations;
|
||||||
|
|
||||||
namespace Spectre.Console.Analyzer
|
namespace Spectre.Console.Analyzer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Analyzer to suggest using available instances of AnsiConsole over the static methods.
|
||||||
|
/// </summary>
|
||||||
|
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||||
|
public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Analyzer to suggest using available instances of AnsiConsole over the static methods.
|
|
||||||
/// </summary>
|
|
||||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
|
||||||
public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer
|
|
||||||
{
|
|
||||||
private static readonly DiagnosticDescriptor _diagnosticDescriptor =
|
private static readonly DiagnosticDescriptor _diagnosticDescriptor =
|
||||||
Descriptors.S1010_FavorInstanceAnsiConsoleOverStatic;
|
Descriptors.S1010_FavorInstanceAnsiConsoleOverStatic;
|
||||||
|
|
||||||
@ -91,5 +91,4 @@ namespace Spectre.Console.Analyzer
|
|||||||
i.Declaration.Type.NormalizeWhitespace().ToString() == "IAnsiConsole" &&
|
i.Declaration.Type.NormalizeWhitespace().ToString() == "IAnsiConsole" &&
|
||||||
(!isStatic ^ i.Modifiers.Any(modifier => modifier.Kind() == SyntaxKind.StaticKeyword)));
|
(!isStatic ^ i.Modifiers.Any(modifier => modifier.Kind() == SyntaxKind.StaticKeyword)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -7,15 +7,15 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|||||||
using Microsoft.CodeAnalysis.Diagnostics;
|
using Microsoft.CodeAnalysis.Diagnostics;
|
||||||
using Microsoft.CodeAnalysis.Operations;
|
using Microsoft.CodeAnalysis.Operations;
|
||||||
|
|
||||||
namespace Spectre.Console.Analyzer
|
namespace Spectre.Console.Analyzer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Analyzer to detect calls to live renderables within a live renderable context.
|
||||||
|
/// </summary>
|
||||||
|
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||||
|
[Shared]
|
||||||
|
public class NoConcurrentLiveRenderablesAnalyzer : SpectreAnalyzer
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Analyzer to detect calls to live renderables within a live renderable context.
|
|
||||||
/// </summary>
|
|
||||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
|
||||||
[Shared]
|
|
||||||
public class NoConcurrentLiveRenderablesAnalyzer : SpectreAnalyzer
|
|
||||||
{
|
|
||||||
private static readonly DiagnosticDescriptor _diagnosticDescriptor =
|
private static readonly DiagnosticDescriptor _diagnosticDescriptor =
|
||||||
Descriptors.S1020_AvoidConcurrentCallsToMultipleLiveRenderables;
|
Descriptors.S1020_AvoidConcurrentCallsToMultipleLiveRenderables;
|
||||||
|
|
||||||
@ -74,5 +74,4 @@ namespace Spectre.Console.Analyzer
|
|||||||
displayString));
|
displayString));
|
||||||
}, OperationKind.Invocation);
|
}, OperationKind.Invocation);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -7,15 +7,15 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|||||||
using Microsoft.CodeAnalysis.Diagnostics;
|
using Microsoft.CodeAnalysis.Diagnostics;
|
||||||
using Microsoft.CodeAnalysis.Operations;
|
using Microsoft.CodeAnalysis.Operations;
|
||||||
|
|
||||||
namespace Spectre.Console.Analyzer
|
namespace Spectre.Console.Analyzer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Analyzer to detect calls to live renderables within a live renderable context.
|
||||||
|
/// </summary>
|
||||||
|
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||||
|
[Shared]
|
||||||
|
public class NoPromptsDuringLiveRenderablesAnalyzer : SpectreAnalyzer
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Analyzer to detect calls to live renderables within a live renderable context.
|
|
||||||
/// </summary>
|
|
||||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
|
||||||
[Shared]
|
|
||||||
public class NoPromptsDuringLiveRenderablesAnalyzer : SpectreAnalyzer
|
|
||||||
{
|
|
||||||
private static readonly DiagnosticDescriptor _diagnosticDescriptor =
|
private static readonly DiagnosticDescriptor _diagnosticDescriptor =
|
||||||
Descriptors.S1021_AvoidPromptCallsDuringLiveRenderables;
|
Descriptors.S1021_AvoidPromptCallsDuringLiveRenderables;
|
||||||
|
|
||||||
@ -80,5 +80,4 @@ namespace Spectre.Console.Analyzer
|
|||||||
displayString));
|
displayString));
|
||||||
}, OperationKind.Invocation);
|
}, OperationKind.Invocation);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using Microsoft.CodeAnalysis.Diagnostics;
|
using Microsoft.CodeAnalysis.Diagnostics;
|
||||||
|
|
||||||
namespace Spectre.Console.Analyzer
|
namespace Spectre.Console.Analyzer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for Spectre analyzers.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class SpectreAnalyzer : DiagnosticAnalyzer
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Base class for Spectre analyzers.
|
|
||||||
/// </summary>
|
|
||||||
public abstract class SpectreAnalyzer : DiagnosticAnalyzer
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Initialize(AnalysisContext context)
|
public override void Initialize(AnalysisContext context)
|
||||||
{
|
{
|
||||||
@ -21,5 +21,4 @@ namespace Spectre.Console.Analyzer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="compilationStartContext">Compilation Start Analysis Context.</param>
|
/// <param name="compilationStartContext">Compilation Start Analysis Context.</param>
|
||||||
protected abstract void AnalyzeCompilation(CompilationStartAnalysisContext compilationStartContext);
|
protected abstract void AnalyzeCompilation(CompilationStartAnalysisContext compilationStartContext);
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,14 +4,14 @@ using Microsoft.CodeAnalysis.CSharp;
|
|||||||
using Microsoft.CodeAnalysis.Diagnostics;
|
using Microsoft.CodeAnalysis.Diagnostics;
|
||||||
using Microsoft.CodeAnalysis.Operations;
|
using Microsoft.CodeAnalysis.Operations;
|
||||||
|
|
||||||
namespace Spectre.Console.Analyzer
|
namespace Spectre.Console.Analyzer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Analyzer to enforce the use of AnsiConsole over System.Console for known methods.
|
||||||
|
/// </summary>
|
||||||
|
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||||
|
public class UseSpectreInsteadOfSystemConsoleAnalyzer : SpectreAnalyzer
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Analyzer to enforce the use of AnsiConsole over System.Console for known methods.
|
|
||||||
/// </summary>
|
|
||||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
|
||||||
public class UseSpectreInsteadOfSystemConsoleAnalyzer : SpectreAnalyzer
|
|
||||||
{
|
|
||||||
private static readonly DiagnosticDescriptor _diagnosticDescriptor =
|
private static readonly DiagnosticDescriptor _diagnosticDescriptor =
|
||||||
Descriptors.S1000_UseAnsiConsoleOverSystemConsole;
|
Descriptors.S1000_UseAnsiConsoleOverSystemConsole;
|
||||||
|
|
||||||
@ -59,5 +59,4 @@ namespace Spectre.Console.Analyzer
|
|||||||
displayString));
|
displayString));
|
||||||
}, OperationKind.Invocation);
|
}, OperationKind.Invocation);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Analyzer
|
namespace Spectre.Console.Analyzer;
|
||||||
|
|
||||||
|
internal static class Constants
|
||||||
{
|
{
|
||||||
internal static class Constants
|
|
||||||
{
|
|
||||||
internal const string StaticInstance = "AnsiConsole";
|
internal const string StaticInstance = "AnsiConsole";
|
||||||
internal const string SpectreConsole = "Spectre.Console";
|
internal const string SpectreConsole = "Spectre.Console";
|
||||||
|
|
||||||
@ -11,5 +11,4 @@ namespace Spectre.Console.Analyzer
|
|||||||
"Spectre.Console.Progress",
|
"Spectre.Console.Progress",
|
||||||
"Spectre.Console.Status",
|
"Spectre.Console.Status",
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,13 +3,13 @@ using Microsoft.CodeAnalysis;
|
|||||||
using static Microsoft.CodeAnalysis.DiagnosticSeverity;
|
using static Microsoft.CodeAnalysis.DiagnosticSeverity;
|
||||||
using static Spectre.Console.Analyzer.Descriptors.Category;
|
using static Spectre.Console.Analyzer.Descriptors.Category;
|
||||||
|
|
||||||
namespace Spectre.Console.Analyzer
|
namespace Spectre.Console.Analyzer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Code analysis descriptors.
|
||||||
|
/// </summary>
|
||||||
|
public static class Descriptors
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Code analysis descriptors.
|
|
||||||
/// </summary>
|
|
||||||
public static class Descriptors
|
|
||||||
{
|
|
||||||
internal enum Category
|
internal enum Category
|
||||||
{
|
{
|
||||||
Usage, // 1xxx
|
Usage, // 1xxx
|
||||||
@ -75,5 +75,4 @@ namespace Spectre.Console.Analyzer
|
|||||||
Usage,
|
Usage,
|
||||||
Warning,
|
Warning,
|
||||||
"Avoid prompting for input while a current renderable is running.");
|
"Avoid prompting for input while a current renderable is running.");
|
||||||
}
|
|
||||||
}
|
}
|
@ -7,13 +7,13 @@ using Microsoft.CodeAnalysis.CSharp;
|
|||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||||
|
|
||||||
namespace Spectre.Console.Analyzer.CodeActions
|
namespace Spectre.Console.Analyzer.CodeActions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Code action to change calls to System.Console to AnsiConsole.
|
||||||
|
/// </summary>
|
||||||
|
public class SwitchToAnsiConsoleAction : CodeAction
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Code action to change calls to System.Console to AnsiConsole.
|
|
||||||
/// </summary>
|
|
||||||
public class SwitchToAnsiConsoleAction : CodeAction
|
|
||||||
{
|
|
||||||
private readonly Document _document;
|
private readonly Document _document;
|
||||||
private readonly InvocationExpressionSyntax _originalInvocation;
|
private readonly InvocationExpressionSyntax _originalInvocation;
|
||||||
|
|
||||||
@ -112,5 +112,4 @@ namespace Spectre.Console.Analyzer.CodeActions
|
|||||||
.WithLeadingTrivia(_originalInvocation.GetLeadingTrivia()))
|
.WithLeadingTrivia(_originalInvocation.GetLeadingTrivia()))
|
||||||
.Expression;
|
.Expression;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -6,15 +6,15 @@ using Microsoft.CodeAnalysis.CodeFixes;
|
|||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using Spectre.Console.Analyzer.CodeActions;
|
using Spectre.Console.Analyzer.CodeActions;
|
||||||
|
|
||||||
namespace Spectre.Console.Analyzer.FixProviders
|
namespace Spectre.Console.Analyzer.FixProviders;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fix provider to change System.Console calls to AnsiConsole calls.
|
||||||
|
/// </summary>
|
||||||
|
[ExportCodeFixProvider(LanguageNames.CSharp)]
|
||||||
|
[Shared]
|
||||||
|
public class StaticAnsiConsoleToInstanceFix : CodeFixProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Fix provider to change System.Console calls to AnsiConsole calls.
|
|
||||||
/// </summary>
|
|
||||||
[ExportCodeFixProvider(LanguageNames.CSharp)]
|
|
||||||
[Shared]
|
|
||||||
public class StaticAnsiConsoleToInstanceFix : CodeFixProvider
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public sealed override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(
|
public sealed override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(
|
||||||
Descriptors.S1010_FavorInstanceAnsiConsoleOverStatic.Id);
|
Descriptors.S1010_FavorInstanceAnsiConsoleOverStatic.Id);
|
||||||
@ -31,5 +31,4 @@ namespace Spectre.Console.Analyzer.FixProviders
|
|||||||
new SwitchToAnsiConsoleAction(context.Document, methodDeclaration, "Convert static AnsiConsole calls to local instance."),
|
new SwitchToAnsiConsoleAction(context.Document, methodDeclaration, "Convert static AnsiConsole calls to local instance."),
|
||||||
context.Diagnostics);
|
context.Diagnostics);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -6,15 +6,15 @@ using Microsoft.CodeAnalysis.CodeFixes;
|
|||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using Spectre.Console.Analyzer.CodeActions;
|
using Spectre.Console.Analyzer.CodeActions;
|
||||||
|
|
||||||
namespace Spectre.Console.Analyzer.FixProviders
|
namespace Spectre.Console.Analyzer.FixProviders;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fix provider to change System.Console calls to AnsiConsole calls.
|
||||||
|
/// </summary>
|
||||||
|
[ExportCodeFixProvider(LanguageNames.CSharp)]
|
||||||
|
[Shared]
|
||||||
|
public class SystemConsoleToAnsiConsoleFix : CodeFixProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Fix provider to change System.Console calls to AnsiConsole calls.
|
|
||||||
/// </summary>
|
|
||||||
[ExportCodeFixProvider(LanguageNames.CSharp)]
|
|
||||||
[Shared]
|
|
||||||
public class SystemConsoleToAnsiConsoleFix : CodeFixProvider
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public sealed override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(
|
public sealed override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(
|
||||||
Descriptors.S1000_UseAnsiConsoleOverSystemConsole.Id);
|
Descriptors.S1000_UseAnsiConsoleOverSystemConsole.Id);
|
||||||
@ -31,5 +31,4 @@ namespace Spectre.Console.Analyzer.FixProviders
|
|||||||
new SwitchToAnsiConsoleAction(context.Document, methodDeclaration, "Convert static call to AnsiConsole to Spectre.Console.AnsiConsole"),
|
new SwitchToAnsiConsoleAction(context.Document, methodDeclaration, "Convert static call to AnsiConsole to Spectre.Console.AnsiConsole"),
|
||||||
context.Diagnostics);
|
context.Diagnostics);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,10 +1,9 @@
|
|||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||||
|
|
||||||
namespace Spectre.Console.Analyzer
|
namespace Spectre.Console.Analyzer;
|
||||||
|
|
||||||
|
internal static class Syntax
|
||||||
{
|
{
|
||||||
internal static class Syntax
|
|
||||||
{
|
|
||||||
public static readonly UsingDirectiveSyntax SpectreUsing = UsingDirective(QualifiedName(IdentifierName("Spectre"), IdentifierName("Console")));
|
public static readonly UsingDirectiveSyntax SpectreUsing = UsingDirective(QualifiedName(IdentifierName("Spectre"), IdentifierName("Console")));
|
||||||
}
|
|
||||||
}
|
}
|
@ -6,13 +6,13 @@ using SixLabors.ImageSharp.Processing;
|
|||||||
using SixLabors.ImageSharp.Processing.Processors.Transforms;
|
using SixLabors.ImageSharp.Processing.Processors.Transforms;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a renderable image.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class CanvasImage : Renderable
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents a renderable image.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class CanvasImage : Renderable
|
|
||||||
{
|
|
||||||
private static readonly IResampler _defaultResampler = KnownResamplers.Bicubic;
|
private static readonly IResampler _defaultResampler = KnownResamplers.Bicubic;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -140,5 +140,4 @@ namespace Spectre.Console
|
|||||||
|
|
||||||
return ((IRenderable)canvas).Render(context, maxWidth);
|
return ((IRenderable)canvas).Render(context, maxWidth);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains extension methods for <see cref="CanvasImage"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class CanvasImageExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Contains extension methods for <see cref="CanvasImage"/>.
|
|
||||||
/// </summary>
|
|
||||||
public static class CanvasImageExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the maximum width of the rendered image.
|
/// Sets the maximum width of the rendered image.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -131,5 +131,4 @@ namespace Spectre.Console
|
|||||||
image.Resampler = KnownResamplers.NearestNeighbor;
|
image.Resampler = KnownResamplers.NearestNeighbor;
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="ICommandInterceptor"/> that triggers a callback when invoked.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class CallbackCommandInterceptor : ICommandInterceptor
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A <see cref="ICommandInterceptor"/> that triggers a callback when invoked.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class CallbackCommandInterceptor : ICommandInterceptor
|
|
||||||
{
|
|
||||||
private readonly Action<CommandContext, CommandSettings> _callback;
|
private readonly Action<CommandContext, CommandSettings> _callback;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -24,5 +24,4 @@ namespace Spectre.Console.Testing
|
|||||||
{
|
{
|
||||||
_callback(context, settings);
|
_callback(context, settings);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a <see cref="CommandApp"/> runtime failure.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class CommandAppFailure
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents a <see cref="CommandApp"/> runtime failure.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class CommandAppFailure
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the exception that was thrown.
|
/// Gets the exception that was thrown.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -25,5 +25,4 @@ namespace Spectre.Console.Testing
|
|||||||
.TrimLines()
|
.TrimLines()
|
||||||
.Trim();
|
.Trim();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the result of a completed <see cref="CommandApp"/> run.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class CommandAppResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents the result of a completed <see cref="CommandApp"/> run.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class CommandAppResult
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the exit code.
|
/// Gets the exit code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -39,5 +39,4 @@ namespace Spectre.Console.Testing
|
|||||||
.TrimLines()
|
.TrimLines()
|
||||||
.Trim();
|
.Trim();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="CommandApp"/> test harness.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class CommandAppTester
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A <see cref="CommandApp"/> test harness.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class CommandAppTester
|
|
||||||
{
|
|
||||||
private Action<CommandApp>? _appConfiguration;
|
private Action<CommandApp>? _appConfiguration;
|
||||||
private Action<IConfigurator>? _configuration;
|
private Action<IConfigurator>? _configuration;
|
||||||
|
|
||||||
@ -131,5 +131,4 @@ namespace Spectre.Console.Testing
|
|||||||
|
|
||||||
return new CommandAppResult(result, output, context, settings);
|
return new CommandAppResult(result, output, context, settings);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is a utility class for implementors of
|
||||||
|
/// <see cref="ITypeRegistrar"/> and corresponding <see cref="ITypeResolver"/>.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class TypeRegistrarBaseTests
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// This is a utility class for implementors of
|
|
||||||
/// <see cref="ITypeRegistrar"/> and corresponding <see cref="ITypeResolver"/>.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class TypeRegistrarBaseTests
|
|
||||||
{
|
|
||||||
private readonly Func<ITypeRegistrar> _registrarFactory;
|
private readonly Func<ITypeRegistrar> _registrarFactory;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -187,5 +187,4 @@ namespace Spectre.Console.Testing
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains extensions for <see cref="string"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class StringExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Contains extensions for <see cref="string"/>.
|
|
||||||
/// </summary>
|
|
||||||
public static class StringExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a new string with all lines trimmed of trailing whitespace.
|
/// Returns a new string with all lines trimmed of trailing whitespace.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -43,5 +43,4 @@ namespace Spectre.Console.Testing
|
|||||||
|
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains extensions for <see cref="Style"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class StyleExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Contains extensions for <see cref="Style"/>.
|
|
||||||
/// </summary>
|
|
||||||
public static class StyleExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the foreground or background color of the specified style.
|
/// Sets the foreground or background color of the specified style.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -21,5 +21,4 @@ namespace Spectre.Console.Testing
|
|||||||
|
|
||||||
return style.Background(color);
|
return style.Background(color);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
internal sealed class NoopCursor : IAnsiConsoleCursor
|
||||||
{
|
{
|
||||||
internal sealed class NoopCursor : IAnsiConsoleCursor
|
|
||||||
{
|
|
||||||
public void Move(CursorDirection direction, int steps)
|
public void Move(CursorDirection direction, int steps)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -13,5 +13,4 @@ namespace Spectre.Console.Testing
|
|||||||
public void Show(bool show)
|
public void Show(bool show)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
internal sealed class NoopExclusivityMode : IExclusivityMode
|
||||||
{
|
{
|
||||||
internal sealed class NoopExclusivityMode : IExclusivityMode
|
|
||||||
{
|
|
||||||
public T Run<T>(Func<T> func)
|
public T Run<T>(Func<T> func)
|
||||||
{
|
{
|
||||||
return func();
|
return func();
|
||||||
@ -14,5 +14,4 @@ namespace Spectre.Console.Testing
|
|||||||
{
|
{
|
||||||
return await func().ConfigureAwait(false);
|
return await func().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents fake capabilities useful in tests.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class TestCapabilities : IReadOnlyCapabilities
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents fake capabilities useful in tests.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class TestCapabilities : IReadOnlyCapabilities
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public ColorSystem ColorSystem { get; set; } = ColorSystem.TrueColor;
|
public ColorSystem ColorSystem { get; set; } = ColorSystem.TrueColor;
|
||||||
|
|
||||||
@ -36,5 +36,4 @@ namespace Spectre.Console.Testing
|
|||||||
{
|
{
|
||||||
return new RenderContext(this);
|
return new RenderContext(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,13 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A testable console.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class TestConsole : IAnsiConsole, IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A testable console.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class TestConsole : IAnsiConsole, IDisposable
|
|
||||||
{
|
|
||||||
private readonly IAnsiConsole _console;
|
private readonly IAnsiConsole _console;
|
||||||
private readonly StringWriter _writer;
|
private readonly StringWriter _writer;
|
||||||
private IAnsiConsoleCursor? _cursor;
|
private IAnsiConsoleCursor? _cursor;
|
||||||
@ -118,5 +118,4 @@ namespace Spectre.Console.Testing
|
|||||||
{
|
{
|
||||||
_cursor = cursor;
|
_cursor = cursor;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains extensions for <see cref="TestConsole"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class TestConsoleExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Contains extensions for <see cref="TestConsole"/>.
|
|
||||||
/// </summary>
|
|
||||||
public static class TestConsoleExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the console's color system.
|
/// Sets the console's color system.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -63,5 +63,4 @@ namespace Spectre.Console.Testing
|
|||||||
console.EmitAnsiSequences = true;
|
console.EmitAnsiSequences = true;
|
||||||
return console;
|
return console;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,13 @@ using System.Collections.Generic;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a testable console input mechanism.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class TestConsoleInput : IAnsiConsoleInput
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents a testable console input mechanism.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class TestConsoleInput : IAnsiConsoleInput
|
|
||||||
{
|
|
||||||
private readonly Queue<ConsoleKeyInfo> _input;
|
private readonly Queue<ConsoleKeyInfo> _input;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -88,5 +88,4 @@ namespace Spectre.Console.Testing
|
|||||||
{
|
{
|
||||||
return Task.FromResult(ReadKey(intercept));
|
return Task.FromResult(ReadKey(intercept));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes an exception to the console.
|
/// Writes an exception to the console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -26,5 +26,4 @@ namespace Spectre.Console
|
|||||||
{
|
{
|
||||||
Console.WriteException(exception, settings);
|
Console.WriteException(exception, settings);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="LiveDisplay"/> instance.
|
/// Creates a new <see cref="LiveDisplay"/> instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -16,5 +16,4 @@ namespace Spectre.Console
|
|||||||
{
|
{
|
||||||
return Console.Live(target);
|
return Console.Live(target);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes the specified markup to the console.
|
/// Writes the specified markup to the console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -66,5 +66,4 @@ namespace Spectre.Console
|
|||||||
{
|
{
|
||||||
Console.MarkupLine(provider, format, args);
|
Console.MarkupLine(provider, format, args);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="Progress"/> instance.
|
/// Creates a new <see cref="Progress"/> instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -22,5 +22,4 @@ namespace Spectre.Console
|
|||||||
{
|
{
|
||||||
return Console.Status();
|
return Console.Status();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Displays a prompt to the user.
|
/// Displays a prompt to the user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -62,5 +62,4 @@ namespace Spectre.Console
|
|||||||
}
|
}
|
||||||
.Show(Console);
|
.Show(Console);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts recording the console output.
|
/// Starts recording the console output.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -66,5 +66,4 @@ namespace Spectre.Console
|
|||||||
|
|
||||||
return _recorder.Export(encoder);
|
return _recorder.Export(encoder);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renders the specified object to the console.
|
/// Renders the specified object to the console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -31,5 +31,4 @@ namespace Spectre.Console
|
|||||||
|
|
||||||
Console.Write(renderable);
|
Console.Write(renderable);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Switches to an alternate screen buffer if the terminal supports it.
|
/// Switches to an alternate screen buffer if the terminal supports it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -15,5 +15,4 @@ namespace Spectre.Console
|
|||||||
{
|
{
|
||||||
Console.AlternateScreen(action);
|
Console.AlternateScreen(action);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
internal static Style CurrentStyle { get; private set; } = Style.Plain;
|
internal static Style CurrentStyle { get; private set; } = Style.Plain;
|
||||||
internal static bool Created { get; private set; }
|
internal static bool Created { get; private set; }
|
||||||
|
|
||||||
@ -59,5 +59,4 @@ namespace Spectre.Console
|
|||||||
{
|
{
|
||||||
CurrentStyle = Style.Plain;
|
CurrentStyle = Style.Plain;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes the specified string value to the console.
|
/// Writes the specified string value to the console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -249,5 +249,4 @@ namespace Spectre.Console
|
|||||||
{
|
{
|
||||||
Console.Write(string.Format(provider, format, args), CurrentStyle);
|
Console.Write(string.Format(provider, format, args), CurrentStyle);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes an empty line to the console.
|
/// Writes an empty line to the console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -269,5 +269,4 @@ namespace Spectre.Console
|
|||||||
{
|
{
|
||||||
Console.WriteLine(string.Format(provider, format, args), CurrentStyle);
|
Console.WriteLine(string.Format(provider, format, args), CurrentStyle);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A console capable of writing ANSI escape sequences.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class AnsiConsole
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A console capable of writing ANSI escape sequences.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class AnsiConsole
|
|
||||||
{
|
|
||||||
private static Recorder? _recorder;
|
private static Recorder? _recorder;
|
||||||
private static Lazy<IAnsiConsole> _console = new Lazy<IAnsiConsole>(
|
private static Lazy<IAnsiConsole> _console = new Lazy<IAnsiConsole>(
|
||||||
() =>
|
() =>
|
||||||
@ -74,5 +74,4 @@ namespace Spectre.Console
|
|||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,13 +3,13 @@ using System.Runtime.InteropServices;
|
|||||||
using Spectre.Console.Enrichment;
|
using Spectre.Console.Enrichment;
|
||||||
using Spectre.Console.Internal;
|
using Spectre.Console.Internal;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Factory for creating an ANSI console.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class AnsiConsoleFactory
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Factory for creating an ANSI console.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class AnsiConsoleFactory
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates an ANSI console.
|
/// Creates an ANSI console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -108,5 +108,4 @@ namespace Spectre.Console
|
|||||||
|
|
||||||
return (supportsAnsi, legacyConsole);
|
return (supportsAnsi, legacyConsole);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,13 +2,13 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents console output.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class AnsiConsoleOutput : IAnsiConsoleOutput
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents console output.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class AnsiConsoleOutput : IAnsiConsoleOutput
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public TextWriter Writer { get; }
|
public TextWriter Writer { get; }
|
||||||
|
|
||||||
@ -54,5 +54,4 @@ namespace Spectre.Console
|
|||||||
System.Console.OutputEncoding = encoding;
|
System.Console.OutputEncoding = encoding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Settings used when building a <see cref="IAnsiConsole"/>.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class AnsiConsoleSettings
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Settings used when building a <see cref="IAnsiConsole"/>.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class AnsiConsoleSettings
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether or
|
/// Gets or sets a value indicating whether or
|
||||||
/// not ANSI escape sequences are supported.
|
/// not ANSI escape sequences are supported.
|
||||||
@ -52,5 +52,4 @@ namespace Spectre.Console
|
|||||||
{
|
{
|
||||||
Enrichment = new ProfileEnrichment();
|
Enrichment = new ProfileEnrichment();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines ANSI escape sequence support.
|
||||||
|
/// </summary>
|
||||||
|
public enum AnsiSupport
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Determines ANSI escape sequence support.
|
|
||||||
/// </summary>
|
|
||||||
public enum AnsiSupport
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ANSI escape sequence support should
|
/// ANSI escape sequence support should
|
||||||
/// be detected by the system.
|
/// be detected by the system.
|
||||||
@ -20,5 +20,4 @@ namespace Spectre.Console
|
|||||||
/// ANSI escape sequences are not supported.
|
/// ANSI escape sequences are not supported.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
No = 2,
|
No = 2,
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a border.
|
||||||
|
/// </summary>
|
||||||
|
public abstract partial class BoxBorder
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents a border.
|
|
||||||
/// </summary>
|
|
||||||
public abstract partial class BoxBorder
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an invisible border.
|
/// Gets an invisible border.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -38,5 +38,4 @@ namespace Spectre.Console
|
|||||||
/// Gets a square border.
|
/// Gets a square border.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static BoxBorder Square { get; } = new SquareBoxBorder();
|
public static BoxBorder Square { get; } = new SquareBoxBorder();
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a border.
|
||||||
|
/// </summary>
|
||||||
|
public abstract partial class BoxBorder
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents a border.
|
|
||||||
/// </summary>
|
|
||||||
public abstract partial class BoxBorder
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the safe border for this border or <c>null</c> if none exist.
|
/// Gets the safe border for this border or <c>null</c> if none exist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -18,5 +18,4 @@ namespace Spectre.Console
|
|||||||
/// <param name="part">The part to get the character representation for.</param>
|
/// <param name="part">The part to get the character representation for.</param>
|
||||||
/// <returns>A character representation of the specified border part.</returns>
|
/// <returns>A character representation of the specified border part.</returns>
|
||||||
public abstract string GetPart(BoxBorderPart part);
|
public abstract string GetPart(BoxBorderPart part);
|
||||||
}
|
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user