Fix build and code structure improvements. New but essential UI functionality. CI improvements. Documentation improvements. AI module improvements.
This commit is contained in:
@@ -61,15 +61,26 @@ public interface IOutputRenderer
|
||||
/// <typeparam name="T">Type of the row item.</typeparam>
|
||||
public sealed class ColumnDefinition<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new column definition.
|
||||
/// </summary>
|
||||
/// <param name="header">Column header text.</param>
|
||||
/// <param name="valueSelector">Function to extract the column value from an item.</param>
|
||||
public ColumnDefinition(string header, Func<T, string?> valueSelector)
|
||||
{
|
||||
Header = header;
|
||||
ValueSelector = valueSelector;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Column header text.
|
||||
/// </summary>
|
||||
public required string Header { get; init; }
|
||||
public string Header { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Function to extract the column value from an item.
|
||||
/// </summary>
|
||||
public required Func<T, string?> ValueSelector { get; init; }
|
||||
public Func<T, string?> ValueSelector { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional minimum width for the column.
|
||||
|
||||
@@ -282,11 +282,10 @@ public sealed class OutputRenderer : IOutputRenderer
|
||||
.Take(8) // Limit to 8 columns for readability
|
||||
.ToList();
|
||||
|
||||
return properties.Select(p => new ColumnDefinition<T>
|
||||
{
|
||||
Header = ToHeaderCase(p.Name),
|
||||
ValueSelector = item => p.GetValue(item)?.ToString()
|
||||
}).ToList();
|
||||
return properties.Select(p => new ColumnDefinition<T>(
|
||||
ToHeaderCase(p.Name),
|
||||
item => p.GetValue(item)?.ToString()
|
||||
)).ToList();
|
||||
}
|
||||
|
||||
private static bool IsSimpleType(Type type)
|
||||
|
||||
75
src/Cli/StellaOps.Cli/Output/OutputRendererExtensions.cs
Normal file
75
src/Cli/StellaOps.Cli/Output/OutputRendererExtensions.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
// Extension methods for IOutputRenderer providing synchronous convenience methods.
|
||||
|
||||
using System.Text.Json;
|
||||
|
||||
namespace StellaOps.Cli.Output;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for IOutputRenderer.
|
||||
/// </summary>
|
||||
public static class OutputRendererExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Write a line to console output (synchronous wrapper).
|
||||
/// </summary>
|
||||
public static void WriteLine(this IOutputRenderer renderer, string message)
|
||||
{
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an empty line to console output.
|
||||
/// </summary>
|
||||
public static void WriteLine(this IOutputRenderer renderer)
|
||||
{
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write JSON output (synchronous wrapper).
|
||||
/// </summary>
|
||||
public static void WriteJson<T>(this IOutputRenderer renderer, T value)
|
||||
{
|
||||
var json = JsonSerializer.Serialize(value, new JsonSerializerOptions { WriteIndented = true });
|
||||
Console.WriteLine(json);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an error message (synchronous wrapper).
|
||||
/// </summary>
|
||||
public static void WriteError(this IOutputRenderer renderer, string message)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.Error.WriteLine($"Error: {message}");
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a success message (synchronous wrapper).
|
||||
/// </summary>
|
||||
public static void WriteSuccess(this IOutputRenderer renderer, string message)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine(message);
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a warning message (synchronous wrapper).
|
||||
/// </summary>
|
||||
public static void WriteWarning(this IOutputRenderer renderer, string message)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine($"Warning: {message}");
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write informational message (synchronous wrapper).
|
||||
/// </summary>
|
||||
public static void WriteInfo(this IOutputRenderer renderer, string message)
|
||||
{
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user