Files
duplicati/Duplicati/CommandLine/ServerUtil/Commands/ListBackups.cs
T
Kenneth Skovhede e3a8f34a67 Fixed issue with not finding backup by name.
Improved error message if it can be extracted from the server response.
2024-09-03 22:02:51 +02:00

29 lines
849 B
C#

using System.CommandLine;
using System.CommandLine.NamingConventionBinder;
namespace Duplicati.CommandLine.ServerUtil.Commands;
public static class ListBackups
{
public static Command Create() =>
new Command("list-backups", "List all backups")
.WithHandler(CommandHandler.Create<Settings>(async (settings) =>
{
var bks = await (await settings.GetConnection()).ListBackups();
if (!bks.Any())
{
Console.WriteLine("No backups found");
return;
}
foreach (var bk in bks)
{
Console.WriteLine($"{bk.ID}: {bk.Name}");
if (!string.IsNullOrEmpty(bk.Description))
Console.WriteLine($" {bk.Description}");
Console.WriteLine();
}
}));
}