mirror of
https://github.com/Stone-Red-Code/DiscordCLI.git
synced 2026-09-04 00:55:58 +02:00
Auto updater cross platform support test1
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DiscordCLI
|
||||
{
|
||||
internal enum PlatformType
|
||||
{
|
||||
Windows,
|
||||
Linux,
|
||||
LinuxARM
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using DSharpPlus.Exceptions;
|
||||
using Stone_Red_Utilities.ConsoleExtentions;
|
||||
using AlwaysUpToDate;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DiscordCLI
|
||||
{
|
||||
@@ -17,12 +18,7 @@ namespace DiscordCLI
|
||||
private CommandsManager commandsManager;
|
||||
private InputManager inputManager;
|
||||
private OutputManager outputManager;
|
||||
|
||||
#if DEBUG
|
||||
private Updater updater = new Updater(new TimeSpan(0), "https://raw.githubusercontent.com/Stone-Red-Code/DiscordCLI/develop/update/updateInfo.json", "./", true);
|
||||
#else
|
||||
private Updater updater = new Updater(new TimeSpan(0), "https://raw.githubusercontent.com/Stone-Red-Code/DiscordCLI/main/update/updateInfo.json", "./", true);
|
||||
#endif
|
||||
private Updater updater;
|
||||
|
||||
public static void Main() => new Program().Setup().GetAwaiter().GetResult();
|
||||
|
||||
@@ -31,6 +27,33 @@ namespace DiscordCLI
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
||||
|
||||
PlatformType platformType;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm || RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
||||
{
|
||||
platformType = PlatformType.LinuxARM;
|
||||
}
|
||||
else
|
||||
{
|
||||
platformType = PlatformType.Linux;
|
||||
}
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
platformType = PlatformType.Windows;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PlatformNotSupportedException("DiscordCLI only supports Windows and Linux!");
|
||||
}
|
||||
#if DEBUG
|
||||
updater = new Updater(new TimeSpan(0), $"https://raw.githubusercontent.com/Stone-Red-Code/DiscordCLI/develop/update/updateInfo{platformType}.json", "./", true);
|
||||
#else
|
||||
updater = new Updater(new TimeSpan(0), $"https://raw.githubusercontent.com/Stone-Red-Code/DiscordCLI/main/update/updateInfo{platformType}.json", "./", true);
|
||||
#endif
|
||||
|
||||
updater.UpdateAvailible += Updater_UpdateAvailible;
|
||||
updater.NoUpdateAvailible += Updater_NoUpdateAvailible;
|
||||
updater.ProgressChanged += Updater_ProgressChanged;
|
||||
@@ -108,6 +131,7 @@ namespace DiscordCLI
|
||||
|
||||
private void Updater_OnException(Exception exception)
|
||||
{
|
||||
ConsoleExt.WriteLine("Update failed!", ConsoleColor.Red);
|
||||
ConsoleExt.WriteLine(exception.Message, ConsoleColor.Red);
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
6b2fcd6f6be795bf368acd9bea6af905c3230f40
|
||||
5819de5694d0ca464238a467fd3b6e9087ce8675
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user