Updated display when installing a new plugin

This commit is contained in:
2023-07-16 00:18:27 +03:00
parent 730b628fe3
commit ac512e3a27
3 changed files with 14 additions and 5 deletions

View File

@@ -129,15 +129,21 @@ public class Plugin : ICommandAction
if (string.IsNullOrEmpty(pluginName) || pluginName.Length < 2)
{
Console.WriteLine("Please specify a plugin name");
Console.Write("Plugin name : ");
pluginName = Console.ReadLine();
if (string.IsNullOrEmpty(pluginName) || pluginName.Length < 2)
{
Console.WriteLine("Invalid plugin name");
break;
}
}
var pluginManager =
new PluginsManager(Program.URLs["PluginList"], Program.URLs["PluginVersions"]);
var pluginData = await pluginManager.GetPluginLinkByName(pluginName);
if (pluginData == null || pluginData.Length == 0)
{
Console.WriteLine("Plugin not found");
Console.WriteLine($"Plugin {pluginName} not found. Please check the spelling and try again.");
break;
}
@@ -150,7 +156,8 @@ public class Plugin : ICommandAction
//download plugin progress bar for linux and windows terminals
var spinner = new Utilities.Utilities.Spinner();
spinner.Start();
await ServerCom.DownloadFileAsync(pluginLink, $"./Data/{pluginType}s/{pluginName}.dll", null);
IProgress<float> progress = new Progress<float>(p => { spinner.Message = $"Downloading {pluginName}... {Math.Round(p,2)}% " ; });
await ServerCom.DownloadFileAsync(pluginLink, $"./Data/{pluginType}s/{pluginName}.dll", progress);
spinner.Stop();
Console.WriteLine();

View File

@@ -205,6 +205,7 @@ public static class Utilities
private bool isRunning;
private int position;
private Thread thread;
public string Message;
public Spinner()
{
@@ -220,7 +221,8 @@ public static class Utilities
{
while (isRunning)
{
Console.Write("\r" + Sequence[position]);
Console.SetCursorPosition(0, Console.CursorTop);
Console.Write(" " + Sequence[position] + " " + Message + " ");
position++;
if (position >= Sequence.Length)
position = 0;

View File

@@ -124,7 +124,7 @@ public class PluginsManager
for (var i = 0; i < len; i++)
{
var contents = lines[i].Split(',');
if (contents[0] == name)
if (contents[0].ToLowerInvariant() == name.ToLowerInvariant())
{
if (contents.Length == 6)
return new[] { contents[2], contents[3], contents[5] };