mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
24 lines
672 B
C#
24 lines
672 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using CliFx.Attributes;
|
|
using CliFx.Models;
|
|
using CliFx.Services;
|
|
|
|
namespace CliFx.Tests.Dummy.Commands
|
|
{
|
|
[Command("sum", Description = "Calculates the sum of all input values.")]
|
|
public class SumCommand : ICommand
|
|
{
|
|
[CommandOption("values", 'v', IsRequired = true, Description = "Input values.")]
|
|
public IReadOnlyList<double> Values { get; set; }
|
|
|
|
public Task ExecuteAsync(CommandContext context)
|
|
{
|
|
var result = Values.Sum();
|
|
context.Output.WriteLine(result);
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
} |