Skip to content

Commit

Permalink
fixed tabing and spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
cschuchardt88 committed Jan 14, 2024
1 parent 5adbf45 commit 956a6b2
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/Neo.CLI/CLI/MainService.Plugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ private void OnInstallCommand(string pluginName)

var result = InstallPluginAsync(pluginName).GetAwaiter().GetResult();
if (result)
ConsoleHelper.Info("", "Install successful, please restart neo-cli.");
{
var asmName = Assembly.GetExecutingAssembly().GetName().Name;
ConsoleHelper.Info("", $"Install successful, please restart \"{asmName}\".");
}
}

/// <summary>
Expand All @@ -55,8 +58,12 @@ private void OnInstallCommand(string pluginName)
[ConsoleCommand("reinstall", Category = "Plugin Commands", Description = "Overwrite existing plugin by force.")]
private void OnReinstallCommand(string pluginName)
{
InstallPluginAsync(pluginName, overWrite: true).GetAwaiter().GetResult();
ConsoleHelper.Warning("Reinstall successful, please restart neo-cli.");
var result = InstallPluginAsync(pluginName, overWrite: true).GetAwaiter().GetResult();
if (result)
{
var asmName = Assembly.GetExecutingAssembly().GetName().Name;
ConsoleHelper.Info("", $"Reinstall successful, please restart \"{asmName}\".");
}
}

/// <summary>
Expand Down Expand Up @@ -178,25 +185,25 @@ private void OnUnInstallCommand(string pluginName)
{
if (!PluginExists(pluginName))
{
ConsoleHelper.Warning("Plugin not found");
ConsoleHelper.Error("Plugin not found");
return;
}

foreach (var p in Plugin.Plugins)
{
try
{
using var reader = File.OpenRead($"./Plugins/{p.Name}/config.json");
using var reader = File.OpenRead($"Plugins/{p.Name}/config.json");
if (new ConfigurationBuilder()
.AddJsonStream(reader)
.Build()
.GetSection("Dependency")
.GetChildren()
.Select(d => d.Get<string>())
.Any(v => v is not null && v.Equals(pluginName, StringComparison.InvariantCultureIgnoreCase)))
.Select(s => s.Get<string>())
.Any(a => a is not null && a.Equals(pluginName, StringComparison.InvariantCultureIgnoreCase)))
{
ConsoleHelper.Error(
$"Can not uninstall. Other plugins depend on this plugin, try `reinstall {pluginName}` if the plugin is broken.");
ConsoleHelper.Error($"{pluginName} is required by other plugins.");
ConsoleHelper.Info($"If plugin is damaged try to reinstall.");
return;
}
}
Expand All @@ -210,7 +217,7 @@ private void OnUnInstallCommand(string pluginName)
Directory.Delete($"Plugins/{pluginName}", true);
}
catch (IOException) { }
ConsoleHelper.Info("Uninstall successful, please restart neo-cli.");
ConsoleHelper.Info("", "Uninstall successful, please restart neo-cli.");
}

/// <summary>
Expand All @@ -229,7 +236,13 @@ private void OnPluginsCommand()
{
var installedPlugin = Plugin.Plugins.SingleOrDefault(pp => string.Equals(pp.Name, f, StringComparison.CurrentCultureIgnoreCase));
if (installedPlugin != null)
ConsoleHelper.Info("", $"[Installed]\t {f,6}\t ", " @", $"{installedPlugin.Version.ToString(3)} {installedPlugin.Description}");
{
var maxLength = plugins.Select(s => s.Length).OrderDescending().First();
string tabs = string.Empty;
if (f.Length < maxLength)
tabs = "\t";
ConsoleHelper.Info("", $"[Installed]\t {f,6}{tabs}", " @", $"{installedPlugin.Version.ToString(3)} {installedPlugin.Description}");
}
else
ConsoleHelper.Info($"[Not Installed]\t {f}");
});
Expand Down

0 comments on commit 956a6b2

Please sign in to comment.