using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Duplicati.Library.Common;
using Duplicati.Library.Utility;
namespace Duplicati.Library.AutoUpdater
{
///
/// Helper method for various packaging related settings
///
public static class PackageHelper
{
///
/// The named executables that are installed via packages
///
public enum NamedExecutable
{
///
/// The primary executable, with an embedded GUI
///
TrayIcon,
///
/// The primary commandline application
///
CommandLine,
///
/// The autoupdater
///
AutoUpdater,
///
/// The server runner
///
Server,
///
/// The windows service helper wrapping the server
///
WindowsService,
///
/// The backend manipulation tool
///
BackendTool,
///
/// The recovery tool
///
RecoveryTool,
///
/// The backend testing tool
///
BackendTester
}
///
/// Returns the operating system mappings of project executables
///
/// The executable to get then name for
/// The name of the executable on the current operating system
/// Note that the values here mirror the values in the ReleaseBuilder tool, so changes should be coordinated between the two
public static string GetExecutableName(NamedExecutable exe)
=> exe switch
{
NamedExecutable.TrayIcon => Platform.IsClientWindows ? "Duplicati.GUI.TrayIcon.exe" : "duplicati",
NamedExecutable.CommandLine => Platform.IsClientWindows ? "Duplicati.CommandLine.exe" : "duplicati-cli",
NamedExecutable.AutoUpdater => Platform.IsClientWindows ? "Duplicati.CommandLine.AutoUpdater.exe" : "duplicati-autoupdater",
NamedExecutable.Server => Platform.IsClientWindows ? "Duplicati.Server.exe" : "duplicati-server",
NamedExecutable.WindowsService => "Duplicati.WindowsServer.exe",
NamedExecutable.BackendTool => Platform.IsClientWindows ? "Duplicati.CommandLine.BackendTool.exe" : "duplicati-backend-tool",
NamedExecutable.RecoveryTool => Platform.IsClientWindows ? "Duplicati.Command.RecoveryTool.exe" : "duplicati-recovery-tool",
NamedExecutable.BackendTester => Platform.IsClientWindows ? "Duplicati.CommandLine.BackendTester.exe" : "duplicati-backend-tester",
_ => throw new ArgumentException($"Named executable not known: {exe}", nameof(exe))
};
}
}