mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Cleanup
This commit is contained in:
@@ -24,7 +24,7 @@ public class ApplicationConfiguration
|
|||||||
public bool IsPreviewModeAllowed { get; }
|
public bool IsPreviewModeAllowed { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="ApplicationConfiguration"/>.
|
/// Initializes an instance of <see cref="ApplicationConfiguration" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ApplicationConfiguration(
|
public ApplicationConfiguration(
|
||||||
IReadOnlyList<Type> commandTypes,
|
IReadOnlyList<Type> commandTypes,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class ApplicationMetadata
|
|||||||
public string? Description { get; }
|
public string? Description { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="ApplicationMetadata"/>.
|
/// Initializes an instance of <see cref="ApplicationMetadata" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ApplicationMetadata(
|
public ApplicationMetadata(
|
||||||
string title,
|
string title,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public sealed class CommandAttribute : Attribute
|
|||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="CommandAttribute"/>.
|
/// Initializes an instance of <see cref="CommandAttribute" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CommandAttribute(string name)
|
public CommandAttribute(string name)
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,7 @@ public sealed class CommandAttribute : Attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="CommandAttribute"/>.
|
/// Initializes an instance of <see cref="CommandAttribute" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CommandAttribute()
|
public CommandAttribute()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public sealed class CommandOptionAttribute : Attribute
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Must contain at least two characters and start with a letter.
|
/// Must contain at least two characters and start with a letter.
|
||||||
/// Either <see cref="Name"/> or <see cref="ShortName"/> must be set.
|
/// Either <see cref="Name" /> or <see cref="ShortName" /> must be set.
|
||||||
/// All options in a command must have unique names (comparison IS NOT case-sensitive).
|
/// All options in a command must have unique names (comparison IS NOT case-sensitive).
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public string? Name { get; }
|
public string? Name { get; }
|
||||||
@@ -23,7 +23,7 @@ public sealed class CommandOptionAttribute : Attribute
|
|||||||
/// Option short name.
|
/// Option short name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Either <see cref="Name"/> or <see cref="ShortName"/> must be set.
|
/// Either <see cref="Name" /> or <see cref="ShortName" /> must be set.
|
||||||
/// All options in a command must have unique short names (comparison IS case-sensitive).
|
/// All options in a command must have unique short names (comparison IS case-sensitive).
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public char? ShortName { get; }
|
public char? ShortName { get; }
|
||||||
@@ -51,7 +51,7 @@ public sealed class CommandOptionAttribute : Attribute
|
|||||||
/// a value expected by the underlying property.
|
/// a value expected by the underlying property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Converter must derive from <see cref="BindingConverter{T}"/>.
|
/// Converter must derive from <see cref="BindingConverter{T}" />.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Type? Converter { get; set; }
|
public Type? Converter { get; set; }
|
||||||
|
|
||||||
@@ -60,12 +60,12 @@ public sealed class CommandOptionAttribute : Attribute
|
|||||||
/// property, after it has been bound.
|
/// property, after it has been bound.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Validators must derive from <see cref="BindingValidator{T}"/>.
|
/// Validators must derive from <see cref="BindingValidator{T}" />.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Type[] Validators { get; set; } = Array.Empty<Type>();
|
public Type[] Validators { get; set; } = Array.Empty<Type>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="CommandOptionAttribute"/>.
|
/// Initializes an instance of <see cref="CommandOptionAttribute" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private CommandOptionAttribute(string? name, char? shortName)
|
private CommandOptionAttribute(string? name, char? shortName)
|
||||||
{
|
{
|
||||||
@@ -74,7 +74,7 @@ public sealed class CommandOptionAttribute : Attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="CommandOptionAttribute"/>.
|
/// Initializes an instance of <see cref="CommandOptionAttribute" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CommandOptionAttribute(string name, char shortName)
|
public CommandOptionAttribute(string name, char shortName)
|
||||||
: this(name, (char?) shortName)
|
: this(name, (char?) shortName)
|
||||||
@@ -82,7 +82,7 @@ public sealed class CommandOptionAttribute : Attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="CommandOptionAttribute"/>.
|
/// Initializes an instance of <see cref="CommandOptionAttribute" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CommandOptionAttribute(string name)
|
public CommandOptionAttribute(string name)
|
||||||
: this(name, null)
|
: this(name, null)
|
||||||
@@ -90,7 +90,7 @@ public sealed class CommandOptionAttribute : Attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="CommandOptionAttribute"/>.
|
/// Initializes an instance of <see cref="CommandOptionAttribute" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CommandOptionAttribute(char shortName)
|
public CommandOptionAttribute(char shortName)
|
||||||
: this(null, (char?) shortName)
|
: this(null, (char?) shortName)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public sealed class CommandParameterAttribute : Attribute
|
|||||||
/// a value expected by the underlying property.
|
/// a value expected by the underlying property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Converter must derive from <see cref="BindingConverter{T}"/>.
|
/// Converter must derive from <see cref="BindingConverter{T}" />.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Type? Converter { get; set; }
|
public Type? Converter { get; set; }
|
||||||
|
|
||||||
@@ -60,12 +60,12 @@ public sealed class CommandParameterAttribute : Attribute
|
|||||||
/// property, after it has been bound.
|
/// property, after it has been bound.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Validators must derive from <see cref="BindingValidator{T}"/>.
|
/// Validators must derive from <see cref="BindingValidator{T}" />.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Type[] Validators { get; set; } = Array.Empty<Type>();
|
public Type[] Validators { get; set; } = Array.Empty<Type>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="CommandParameterAttribute"/>.
|
/// Initializes an instance of <see cref="CommandParameterAttribute" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CommandParameterAttribute(int order)
|
public CommandParameterAttribute(int order)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class CliApplication
|
|||||||
private readonly CommandBinder _commandBinder;
|
private readonly CommandBinder _commandBinder;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="CliApplication"/>.
|
/// Initializes an instance of <see cref="CliApplication" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CliApplication(
|
public CliApplication(
|
||||||
ApplicationMetadata metadata,
|
ApplicationMetadata metadata,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ using CliFx.Utils.Extensions;
|
|||||||
namespace CliFx;
|
namespace CliFx;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Builder for <see cref="CliApplication"/>.
|
/// Builder for <see cref="CliApplication" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class CliApplicationBuilder
|
public partial class CliApplicationBuilder
|
||||||
{
|
{
|
||||||
@@ -58,8 +58,8 @@ public partial class CliApplicationBuilder
|
|||||||
/// Adds commands from the specified assembly to the application.
|
/// Adds commands from the specified assembly to the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This method looks for public non-abstract classes that implement <see cref="ICommand"/>
|
/// This method looks for public non-abstract classes that implement <see cref="ICommand" />
|
||||||
/// and are annotated by <see cref="CommandAttribute"/>.
|
/// and are annotated by <see cref="CommandAttribute" />.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public CliApplicationBuilder AddCommandsFrom(Assembly commandAssembly)
|
public CliApplicationBuilder AddCommandsFrom(Assembly commandAssembly)
|
||||||
{
|
{
|
||||||
@@ -73,8 +73,8 @@ public partial class CliApplicationBuilder
|
|||||||
/// Adds commands from the specified assemblies to the application.
|
/// Adds commands from the specified assemblies to the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This method looks for public non-abstract classes that implement <see cref="ICommand"/>
|
/// This method looks for public non-abstract classes that implement <see cref="ICommand" />
|
||||||
/// and are annotated by <see cref="CommandAttribute"/>.
|
/// and are annotated by <see cref="CommandAttribute" />.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public CliApplicationBuilder AddCommandsFrom(IEnumerable<Assembly> commandAssemblies)
|
public CliApplicationBuilder AddCommandsFrom(IEnumerable<Assembly> commandAssemblies)
|
||||||
{
|
{
|
||||||
@@ -88,8 +88,8 @@ public partial class CliApplicationBuilder
|
|||||||
/// Adds commands from the calling assembly to the application.
|
/// Adds commands from the calling assembly to the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This method looks for public non-abstract classes that implement <see cref="ICommand"/>
|
/// This method looks for public non-abstract classes that implement <see cref="ICommand" />
|
||||||
/// and are annotated by <see cref="CommandAttribute"/>.
|
/// and are annotated by <see cref="CommandAttribute" />.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public CliApplicationBuilder AddCommandsFromThisAssembly() => AddCommandsFrom(Assembly.GetCallingAssembly());
|
public CliApplicationBuilder AddCommandsFromThisAssembly() => AddCommandsFrom(Assembly.GetCallingAssembly());
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ public partial class CliApplicationBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configures the application to use the specified implementation of <see cref="IConsole"/>.
|
/// Configures the application to use the specified implementation of <see cref="IConsole" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CliApplicationBuilder UseConsole(IConsole console)
|
public CliApplicationBuilder UseConsole(IConsole console)
|
||||||
{
|
{
|
||||||
@@ -168,7 +168,7 @@ public partial class CliApplicationBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configures the application to use the specified implementation of <see cref="ITypeActivator"/>.
|
/// Configures the application to use the specified implementation of <see cref="ITypeActivator" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CliApplicationBuilder UseTypeActivator(ITypeActivator typeActivator)
|
public CliApplicationBuilder UseTypeActivator(ITypeActivator typeActivator)
|
||||||
{
|
{
|
||||||
@@ -189,7 +189,7 @@ public partial class CliApplicationBuilder
|
|||||||
UseTypeActivator(serviceProvider.GetService);
|
UseTypeActivator(serviceProvider.GetService);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a configured instance of <see cref="CliApplication"/>.
|
/// Creates a configured instance of <see cref="CliApplication" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CliApplication Build()
|
public CliApplication Build()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public partial class CliFxException : Exception
|
|||||||
public bool ShowHelp { get; }
|
public bool ShowHelp { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="CliFxException"/>.
|
/// Initializes an instance of <see cref="CliFxException" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CliFxException(
|
public CliFxException(
|
||||||
string message,
|
string message,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace CliFx.Exceptions;
|
|||||||
public class CommandException : CliFxException
|
public class CommandException : CliFxException
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="CommandException"/>.
|
/// Initializes an instance of <see cref="CommandException" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CommandException(
|
public CommandException(
|
||||||
string message,
|
string message,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class BindingValidationError
|
|||||||
public string Message { get; }
|
public string Message { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="BindingValidationError"/>.
|
/// Initializes an instance of <see cref="BindingValidationError" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BindingValidationError(string message) => Message = message;
|
public BindingValidationError(string message) => Message = message;
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ public abstract class BindingValidator<T> : IBindingValidator
|
|||||||
/// Returns null if validation is successful, or an error in case of failure.
|
/// Returns null if validation is successful, or an error in case of failure.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// You can use the utility methods <see cref="Ok"/> and <see cref="Error"/> to
|
/// You can use the utility methods <see cref="Ok" /> and <see cref="Error" /> to
|
||||||
/// create an appropriate result.
|
/// create an appropriate result.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public abstract BindingValidationError? Validate(T? value);
|
public abstract BindingValidationError? Validate(T? value);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace CliFx;
|
|||||||
public interface ICommand
|
public interface ICommand
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes the command using the specified implementation of <see cref="IConsole"/>.
|
/// Executes the command using the specified implementation of <see cref="IConsole" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If the execution of the command is not asynchronous, simply end the method with
|
/// If the execution of the command is not asynchronous, simply end the method with
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
namespace CliFx.Infrastructure;
|
namespace CliFx.Infrastructure;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements a <see cref="TextReader"/> for reading characters from a console stream.
|
/// Implements a <see cref="TextReader" /> for reading characters from a console stream.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// Both the underlying stream AND the stream reader must be synchronized!
|
// Both the underlying stream AND the stream reader must be synchronized!
|
||||||
// https://github.com/Tyrrrz/CliFx/issues/123
|
// https://github.com/Tyrrrz/CliFx/issues/123
|
||||||
@@ -19,7 +19,7 @@ public partial class ConsoleReader : StreamReader
|
|||||||
public IConsole Console { get; }
|
public IConsole Console { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="ConsoleReader"/>.
|
/// Initializes an instance of <see cref="ConsoleReader" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ConsoleReader(IConsole console, Stream stream, Encoding encoding)
|
public ConsoleReader(IConsole console, Stream stream, Encoding encoding)
|
||||||
: base(stream, encoding, false, 4096)
|
: base(stream, encoding, false, 4096)
|
||||||
@@ -28,7 +28,7 @@ public partial class ConsoleReader : StreamReader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="ConsoleReader"/>.
|
/// Initializes an instance of <see cref="ConsoleReader" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ConsoleReader(IConsole console, Stream stream)
|
public ConsoleReader(IConsole console, Stream stream)
|
||||||
: this(console, stream, System.Console.InputEncoding)
|
: this(console, stream, System.Console.InputEncoding)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using CliFx.Utils;
|
|||||||
namespace CliFx.Infrastructure;
|
namespace CliFx.Infrastructure;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements a <see cref="TextWriter"/> for writing characters to a console stream.
|
/// Implements a <see cref="TextWriter" /> for writing characters to a console stream.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// Both the underlying stream AND the stream writer must be synchronized!
|
// Both the underlying stream AND the stream writer must be synchronized!
|
||||||
// https://github.com/Tyrrrz/CliFx/issues/123
|
// https://github.com/Tyrrrz/CliFx/issues/123
|
||||||
@@ -20,7 +20,7 @@ public partial class ConsoleWriter : StreamWriter
|
|||||||
public IConsole Console { get; }
|
public IConsole Console { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="ConsoleWriter"/>.
|
/// Initializes an instance of <see cref="ConsoleWriter" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ConsoleWriter(IConsole console, Stream stream, Encoding encoding)
|
public ConsoleWriter(IConsole console, Stream stream, Encoding encoding)
|
||||||
: base(stream, encoding.WithoutPreamble(), 256)
|
: base(stream, encoding.WithoutPreamble(), 256)
|
||||||
@@ -29,7 +29,7 @@ public partial class ConsoleWriter : StreamWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="ConsoleWriter"/>.
|
/// Initializes an instance of <see cref="ConsoleWriter" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ConsoleWriter(IConsole console, Stream stream)
|
public ConsoleWriter(IConsole console, Stream stream)
|
||||||
: this(console, stream, System.Console.OutputEncoding)
|
: this(console, stream, System.Console.OutputEncoding)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using CliFx.Exceptions;
|
|||||||
namespace CliFx.Infrastructure;
|
namespace CliFx.Infrastructure;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implementation of <see cref="ITypeActivator"/> that instantiates an object
|
/// Implementation of <see cref="ITypeActivator" /> that instantiates an object
|
||||||
/// by using its parameterless constructor.
|
/// by using its parameterless constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DefaultTypeActivator : ITypeActivator
|
public class DefaultTypeActivator : ITypeActivator
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using CliFx.Exceptions;
|
|||||||
namespace CliFx.Infrastructure;
|
namespace CliFx.Infrastructure;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implementation of <see cref="ITypeActivator"/> that instantiates an object
|
/// Implementation of <see cref="ITypeActivator" /> that instantiates an object
|
||||||
/// by using a predefined function.
|
/// by using a predefined function.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DelegateTypeActivator : ITypeActivator
|
public class DelegateTypeActivator : ITypeActivator
|
||||||
@@ -12,7 +12,7 @@ public class DelegateTypeActivator : ITypeActivator
|
|||||||
private readonly Func<Type, object> _func;
|
private readonly Func<Type, object> _func;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="DelegateTypeActivator"/>.
|
/// Initializes an instance of <see cref="DelegateTypeActivator" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DelegateTypeActivator(Func<Type, object> func) => _func = func;
|
public DelegateTypeActivator(Func<Type, object> func) => _func = func;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Threading;
|
|||||||
namespace CliFx.Infrastructure;
|
namespace CliFx.Infrastructure;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implementation of <see cref="IConsole"/> that uses the provided fake
|
/// Implementation of <see cref="IConsole" /> that uses the provided fake
|
||||||
/// standard input, output, and error streams.
|
/// standard input, output, and error streams.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
@@ -54,7 +54,7 @@ public class FakeConsole : IConsole, IDisposable
|
|||||||
public int CursorTop { get; set; }
|
public int CursorTop { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="FakeConsole"/>.
|
/// Initializes an instance of <see cref="FakeConsole" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FakeConsole(Stream? input = null, Stream? output = null, Stream? error = null)
|
public FakeConsole(Stream? input = null, Stream? output = null, Stream? error = null)
|
||||||
{
|
{
|
||||||
@@ -73,7 +73,7 @@ public class FakeConsole : IConsole, IDisposable
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enqueues a simulated key press, which can then be read by calling <see cref="ReadKey"/>.
|
/// Enqueues a simulated key press, which can then be read by calling <see cref="ReadKey" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void EnqueueKey(ConsoleKeyInfo key) => _keys.Enqueue(key);
|
public void EnqueueKey(ConsoleKeyInfo key) => _keys.Enqueue(key);
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ public class FakeConsole : IConsole, IDisposable
|
|||||||
/// Sends a cancellation signal to the currently executing command.
|
/// Sends a cancellation signal to the currently executing command.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If the command is not cancellation-aware (i.e. it doesn't call <see cref="IConsole.RegisterCancellationHandler"/>),
|
/// If the command is not cancellation-aware (i.e. it doesn't call <see cref="IConsole.RegisterCancellationHandler" />),
|
||||||
/// this method will not have any effect.
|
/// this method will not have any effect.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public void RequestCancellation(TimeSpan? delay = null)
|
public void RequestCancellation(TimeSpan? delay = null)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace CliFx.Infrastructure;
|
namespace CliFx.Infrastructure;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implementation of <see cref="IConsole"/> that uses fake
|
/// Implementation of <see cref="IConsole" /> that uses fake
|
||||||
/// standard input, output, and error streams backed by in-memory stores.
|
/// standard input, output, and error streams backed by in-memory stores.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
@@ -24,7 +24,7 @@ public class FakeInMemoryConsole : FakeConsole
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="FakeInMemoryConsole"/>.
|
/// Initializes an instance of <see cref="FakeInMemoryConsole" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FakeInMemoryConsole()
|
public FakeInMemoryConsole()
|
||||||
: this(new MemoryStream(), new MemoryStream(), new MemoryStream())
|
: this(new MemoryStream(), new MemoryStream(), new MemoryStream())
|
||||||
|
|||||||
@@ -105,12 +105,12 @@ public interface IConsole
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extensions for <see cref="IConsole"/>.
|
/// Extensions for <see cref="IConsole" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ConsoleExtensions
|
public static class ConsoleExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the specified foreground color and returns an <see cref="IDisposable"/>
|
/// Sets the specified foreground color and returns an <see cref="IDisposable" />
|
||||||
/// that will reset the color back to its previous value upon disposal.
|
/// that will reset the color back to its previous value upon disposal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IDisposable WithForegroundColor(this IConsole console, ConsoleColor foregroundColor)
|
public static IDisposable WithForegroundColor(this IConsole console, ConsoleColor foregroundColor)
|
||||||
@@ -122,7 +122,7 @@ public static class ConsoleExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the specified background color and returns an <see cref="IDisposable"/>
|
/// Sets the specified background color and returns an <see cref="IDisposable" />
|
||||||
/// that will reset the color back to its previous value upon disposal.
|
/// that will reset the color back to its previous value upon disposal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IDisposable WithBackgroundColor(this IConsole console, ConsoleColor backgroundColor)
|
public static IDisposable WithBackgroundColor(this IConsole console, ConsoleColor backgroundColor)
|
||||||
@@ -134,7 +134,7 @@ public static class ConsoleExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the specified foreground and background colors and returns an <see cref="IDisposable"/>
|
/// Sets the specified foreground and background colors and returns an <see cref="IDisposable" />
|
||||||
/// that will reset the colors back to their previous values upon disposal.
|
/// that will reset the colors back to their previous values upon disposal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IDisposable WithColors(
|
public static IDisposable WithColors(
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Threading;
|
|||||||
namespace CliFx.Infrastructure;
|
namespace CliFx.Infrastructure;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implementation of <see cref="IConsole"/> that represents the real system console.
|
/// Implementation of <see cref="IConsole" /> that represents the real system console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SystemConsole : IConsole, IDisposable
|
public class SystemConsole : IConsole, IDisposable
|
||||||
{
|
{
|
||||||
@@ -71,7 +71,7 @@ public class SystemConsole : IConsole, IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an instance of <see cref="SystemConsole"/>.
|
/// Initializes an instance of <see cref="SystemConsole" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SystemConsole()
|
public SystemConsole()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user