feat(CommandManager): Add ReadDocument command.

This commit is contained in:
Developer 02
2025-04-22 23:47:30 +02:00
parent 975beff416
commit 8785505a91
5 changed files with 34 additions and 5 deletions

View File

@@ -1,11 +1,19 @@
using CommandDotNet;
using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.Documents.Queries.Read;
using MediatR;
using System.Reflection;
using System.Text.Json;
namespace EnvelopeGenerator.Terminal;
public class CommandManager(IEnvelopeReceiverService envelopeReceiverService)
public class CommandManager(IEnvelopeReceiverService envelopeReceiverService, IMediator mediator)
{
private static JsonSerializerOptions Options = new ()
{
WriteIndented = true // <-- Bu satır okunabilir JSON için önemli
};
[DefaultCommand]
public void Execute([Option(Description = "print envelope generator termianal version.")] bool version)
{
@@ -15,4 +23,12 @@ public class CommandManager(IEnvelopeReceiverService envelopeReceiverService)
[Subcommand]
public IEnvelopeReceiverService EnvelopeReceiver => envelopeReceiverService;
[Command]
public async Task ReadDocument(IConsole console, int? id = null, int? envelopeId = null)
{
ReadDocumentQuery query = new(id, envelopeId);
var document = await mediator.Send(query);
console.WriteLine(JsonSerializer.Serialize(document, Options));
}
}

View File

@@ -5,8 +5,6 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<ItemGroup>