. "$PSScriptRoot/../../lib/SoftwareManagement.ps1";
. "$PSScriptRoot/../../../lib/Software.ps1";

& {
    . "$PSScriptRoot/../../lib/Restoration.ps1";
    Export-ModuleMember -Function @();

    $getInstallPath = {
        return "$((Get-KnownFolder -SpecialFolder ProgramFilesX86).Path)/osu!";
    };

    Start-SoftwareInstaller @args `
        -Installer {
            Install-ChocoPackage osu;
            Remove-DesktopIcon "*osu*";
        } `
        -Backup {
            param([string] $Name)

            Add-BackupArtifacts -Source (& $getInstallPath) -Path "$Name" `
                -Include @(
                    "Screenshots",
                    "Skins",
                    "Songs",
                    "osu!.cfg",
                    "scores.db"
                );
        } `
        -Configurator {
            param([string] $Name)

            Expand-BackupArtifacts -Path "$Name" -Target (& $getInstallPath);
        } `
        -UserBackup {
            param(
                [string] $Name,
                [hashtable] $Arguments
            )

            $user = $Arguments.Name;
            Add-BackupArtifacts -Source "$(& $getInstallPath)/osu!.$user.cfg" -User $user -Path "$Name/osu!.cfg";
        } `
        -UserConfigurator {
            param([hashtable] $Arguments)
            $name = $Arguments.Name;
            Expand-BackupArtifacts -User $name -Path "$Name/osu!.cfg" -Target "$(& $getInstallPath)/osu!.$name.cfg";
        };
} @args;