mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e97ebe7f0 | ||
|
|
64cbdaaeab |
@@ -1,3 +1,8 @@
|
||||
### v2.3 (12-Jul-2022)
|
||||
|
||||
- Added console dimension properties `WindowWidth` and `WindowHeight` to `IConsole` interface and implementing classes.
|
||||
- Improved inline documentation for members of `IConsole` interface.
|
||||
|
||||
### v2.2.6 (14-Jun-2022)
|
||||
|
||||
- Added an overload of `CliApplicationBuilder.UseTypeActivator(...)` that accepts an instance of `IServiceProvider`. This slightly simplifies integration with many DI containers.
|
||||
|
||||
@@ -57,6 +57,8 @@ public class Command : ICommand
|
||||
console.ResetColor();
|
||||
console.ForegroundColor = ConsoleColor.DarkMagenta;
|
||||
console.BackgroundColor = ConsoleColor.DarkMagenta;
|
||||
console.WindowWidth = 100;
|
||||
console.WindowHeight = 25;
|
||||
console.CursorLeft = 42;
|
||||
console.CursorTop = 24;
|
||||
|
||||
@@ -90,6 +92,8 @@ public class Command : ICommand
|
||||
Console.BackgroundColor.Should().NotBe(ConsoleColor.DarkMagenta);
|
||||
|
||||
// This fails because tests don't spawn a console window
|
||||
//Console.WindowWidth.Should().Be(100);
|
||||
//Console.WindowHeight.Should().Be(25);
|
||||
//Console.CursorLeft.Should().NotBe(42);
|
||||
//Console.CursorTop.Should().NotBe(24);
|
||||
|
||||
|
||||
@@ -42,11 +42,10 @@ public class FakeConsole : IConsole, IDisposable
|
||||
public ConsoleColor BackgroundColor { get; set; } = ConsoleColor.Black;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ResetColor()
|
||||
{
|
||||
ForegroundColor = ConsoleColor.Gray;
|
||||
BackgroundColor = ConsoleColor.Black;
|
||||
}
|
||||
public int WindowWidth { get; set; } = 232; // Windows defaults
|
||||
|
||||
/// <inheritdoc />
|
||||
public int WindowHeight { get; set; } = 14; // Windows defaults
|
||||
|
||||
/// <inheritdoc />
|
||||
public int CursorLeft { get; set; }
|
||||
@@ -77,7 +76,14 @@ public class FakeConsole : IConsole, IDisposable
|
||||
/// Enqueues a simulated key press, which can then be read by calling <see cref="ReadKey"/>.
|
||||
/// </summary>
|
||||
public void EnqueueKey(ConsoleKeyInfo key) => _keys.Enqueue(key);
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ResetColor()
|
||||
{
|
||||
ForegroundColor = ConsoleColor.Gray;
|
||||
BackgroundColor = ConsoleColor.Black;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Clear()
|
||||
{
|
||||
@@ -85,7 +91,7 @@ public class FakeConsole : IConsole, IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
public CancellationToken RegisterCancellationHandler() => _cancellationTokenSource.Token;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sends a cancellation signal to the currently executing command.
|
||||
/// </summary>
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface IConsole
|
||||
ConsoleReader Input { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the input stream is redirected.
|
||||
/// Gets a value that indicates whether input has been redirected from the standard input stream.
|
||||
/// </summary>
|
||||
bool IsInputRedirected { get; }
|
||||
|
||||
@@ -25,7 +25,7 @@ public interface IConsole
|
||||
ConsoleWriter Output { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the output stream is redirected.
|
||||
/// Gets a value that indicates whether output has been redirected from the standard output stream.
|
||||
/// </summary>
|
||||
bool IsOutputRedirected { get; }
|
||||
|
||||
@@ -35,32 +35,37 @@ public interface IConsole
|
||||
ConsoleWriter Error { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the error stream is redirected.
|
||||
/// Gets a value that indicates whether error output has been redirected from the standard error stream.
|
||||
/// </summary>
|
||||
bool IsErrorRedirected { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current foreground color.
|
||||
/// Gets or sets the foreground color of the console
|
||||
/// </summary>
|
||||
ConsoleColor ForegroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Current background color.
|
||||
/// Gets or sets the background color of the console.
|
||||
/// </summary>
|
||||
ConsoleColor BackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Resets foreground and background colors to their default values.
|
||||
/// Gets or sets the width of the console window.
|
||||
/// </summary>
|
||||
void ResetColor();
|
||||
int WindowWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cursor left offset.
|
||||
/// Gets or sets the height of the console window.
|
||||
/// </summary>
|
||||
int WindowHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the column position of the cursor within the buffer area.
|
||||
/// </summary>
|
||||
int CursorLeft { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cursor top offset.
|
||||
/// Gets or sets the row position of the cursor within the buffer area.
|
||||
/// </summary>
|
||||
int CursorTop { get; set; }
|
||||
|
||||
@@ -68,12 +73,17 @@ public interface IConsole
|
||||
/// Obtains the next character or function key pressed by the user.
|
||||
/// </summary>
|
||||
ConsoleKeyInfo ReadKey(bool intercept = false);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets the foreground and background console colors to their defaults.
|
||||
/// </summary>
|
||||
void ResetColor();
|
||||
|
||||
/// <summary>
|
||||
/// Clears the console buffer and corresponding console window of display information.
|
||||
/// </summary>
|
||||
void Clear();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Registers a handler for the interrupt signal (Ctrl+C) on the console and returns
|
||||
/// a token representing the cancellation request.
|
||||
|
||||
@@ -41,7 +41,21 @@ public class SystemConsole : IConsole, IDisposable
|
||||
get => Console.BackgroundColor;
|
||||
set => Console.BackgroundColor = value;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public int WindowWidth
|
||||
{
|
||||
get => Console.WindowWidth;
|
||||
set => Console.WindowWidth = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int WindowHeight
|
||||
{
|
||||
get => Console.WindowHeight;
|
||||
set => Console.WindowHeight = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int CursorLeft
|
||||
{
|
||||
@@ -66,15 +80,15 @@ public class SystemConsole : IConsole, IDisposable
|
||||
Error = ConsoleWriter.Create(this, Console.OpenStandardError());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ConsoleKeyInfo ReadKey(bool intercept = false) => Console.ReadKey(intercept);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ResetColor() => Console.ResetColor();
|
||||
|
||||
/// <inheritdoc />
|
||||
public ConsoleKeyInfo ReadKey(bool intercept = false) => Console.ReadKey(intercept);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Clear() => Console.Clear();
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public CancellationToken RegisterCancellationHandler()
|
||||
{
|
||||
@@ -95,7 +109,7 @@ public class SystemConsole : IConsole, IDisposable
|
||||
|
||||
return (_cancellationTokenSource = cts).Token;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>2.2.6</Version>
|
||||
<Version>2.3</Version>
|
||||
<Company>Tyrrrz</Company>
|
||||
<Copyright>Copyright (C) Oleksii Holub</Copyright>
|
||||
<LangVersion>latest</LangVersion>
|
||||
|
||||
Reference in New Issue
Block a user