예제 #1
0
        public void Execute(ICommandContext context)
        {
            if (context.Parameters.Length != 2)
            {
                throw new CommandWrongUsageException();
            }

            NuGetPluginLoader pm = (NuGetPluginLoader)context.Container.Resolve <IPluginLoader>("nuget_plugins");

            string repoName   = context.Parameters.Get <string>(0);
            string pluginName = context.Parameters.Get <string>(1);

            var repo = pm.Repositories.FirstOrDefault(c
                                                      => c.Name.Equals(repoName, StringComparison.OrdinalIgnoreCase));

            if (repo == null)
            {
                context.User.SendMessage("Repository not found: " + repoName, Color.DarkRed);
                return;
            }

            if (!pm.Uninstall(repoName, pluginName))
            {
                context.User.SendMessage($"Failed to uninstall \"{pluginName}\"", Color.DarkRed);
                return;
            }

            context.User.SendMessage($"Successfully uninstalled  \"{pluginName}\"", Color.DarkGreen);
            context.User.SendMessage("Restart server to finish uninstall.", Color.Red);
        }
예제 #2
0
        public void Execute(ICommandContext context)
        {
            if (context.Parameters.Length < 2)
            {
                throw new CommandWrongUsageException();
            }

            NuGetPluginLoader pm = (NuGetPluginLoader)context.Container.Resolve <IPluginLoader>("nuget_plugins");

            var args = context.Parameters.ToList();

            string repoName   = args[0];
            string pluginName = args[1];
            string version    = null;
            bool   isPre      = false;

            if (args.Contains("-Pre"))
            {
                isPre = true;
                args.Remove("-Pre");
            }

            if (args.Count > 2)
            {
                version = args[2];
            }

            var repo = pm.Repositories.FirstOrDefault(c
                                                      => c.Name.Equals(repoName, StringComparison.OrdinalIgnoreCase));

            if (repo == null)
            {
                context.User.SendMessage("Repository not found: " + repoName, Color.DarkRed);
                return;
            }

            var result = pm.Install(repoName, pluginName, version, isPre);

            if (result != NuGetInstallResult.Success)
            {
                context.User.SendMessage($"Failed to install \"{pluginName}\": " + result, Color.DarkRed);
                return;
            }

            if (!pm.LoadPlugin(repoName, pluginName))
            {
                context.User.SendMessage($"Failed to initialize \"{pluginName}\"", Color.DarkRed);
                pm.Uninstall(repoName, pluginName);
                return;
            }

            context.User.SendMessage($"Successfully installed \"{pluginName}\"", Color.DarkGreen);
        }