25 lines
741 B
C#
25 lines
741 B
C#
|
|
// Copyright (c) The Geekeey Authors
|
||
|
|
// SPDX-License-Identifier: EUPL-1.2
|
||
|
|
|
||
|
|
using Spectre.Console.Cli;
|
||
|
|
|
||
|
|
internal sealed class EchoCommand : AsyncOutputCommand<EchoCommand.Settings>
|
||
|
|
{
|
||
|
|
public sealed class Settings : OutputCommandSettings
|
||
|
|
{
|
||
|
|
[CommandOption("--separator <char>")] public string Separator { get; init; } = " ";
|
||
|
|
[CommandArgument(0, "[line]")] public string[] Items { get; init; } = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
public override async Task<int> ExecuteAsync(CommandContext context, Settings settings, CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
using var output = Output.Connect();
|
||
|
|
|
||
|
|
foreach (var writer in output.GetWriters(settings.Target))
|
||
|
|
{
|
||
|
|
await writer.WriteLineAsync(string.Join(settings.Separator, settings.Items));
|
||
|
|
}
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
}
|