using System;
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,
///
/// The SharpAESCrypt tool
///
SharpAESCrypt,
///
/// The snapshot tool
///
Snapshots,
///
/// The server utility
///
ServerUtil,
///
/// The service wrapping the server
///
Service
}
///
/// 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 => OperatingSystem.IsWindows() ? "Duplicati.GUI.TrayIcon.exe" : "duplicati",
NamedExecutable.CommandLine => OperatingSystem.IsWindows() ? "Duplicati.CommandLine.exe" : "duplicati-cli",
NamedExecutable.AutoUpdater => OperatingSystem.IsWindows() ? "Duplicati.CommandLine.AutoUpdater.exe" : "duplicati-autoupdater",
NamedExecutable.Server => OperatingSystem.IsWindows() ? "Duplicati.Server.exe" : "duplicati-server",
NamedExecutable.WindowsService => "Duplicati.WindowsServer.exe",
NamedExecutable.BackendTool => OperatingSystem.IsWindows() ? "Duplicati.CommandLine.BackendTool.exe" : "duplicati-backend-tool",
NamedExecutable.RecoveryTool => OperatingSystem.IsWindows() ? "Duplicati.CommandLine.RecoveryTool.exe" : "duplicati-recovery-tool",
NamedExecutable.BackendTester => OperatingSystem.IsWindows() ? "Duplicati.CommandLine.BackendTester.exe" : "duplicati-backend-tester",
NamedExecutable.SharpAESCrypt => OperatingSystem.IsWindows() ? "Duplicati.CommandLine.SharpAESCrypt.exe" : "duplicati-aescrypt",
NamedExecutable.Snapshots => OperatingSystem.IsWindows() ? "Duplicati.CommandLine.Snapshots.exe" : "duplicati-snapshots",
NamedExecutable.ServerUtil => OperatingSystem.IsWindows() ? "Duplicati.CommandLine.ServerUtil.exe" : "duplicati-server-util",
NamedExecutable.Service => OperatingSystem.IsWindows() ? "Duplicati.Service.exe" : "duplicati-service",
_ => throw new ArgumentException($"Named executable not known: {exe}", nameof(exe))
};
}
}