Skip to content

Commit

Permalink
Merge pull request #636 from RichardLake/Issue605
Browse files Browse the repository at this point in the history
CmdLine: Run scan before install/update, better msg on autoinstalled mods.
  • Loading branch information
pjf committed Dec 19, 2014
2 parents 4db2123 + 64a9add commit 2132b46
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
9 changes: 9 additions & 0 deletions CKAN/CmdLine/Action/Upgrade.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace CKAN.CmdLine
Expand Down Expand Up @@ -60,6 +61,14 @@ public int RunCommand(CKAN.KSP ksp, object raw_options)
}


var auto_detected_modules = to_upgrade.Where(module => ksp.Registry.IsAutodetected(module.identifier)).ToList();
foreach (var module in auto_detected_modules.Select(mod => mod.identifier))
{
User.RaiseMessage("Cannot upgrade {0} as it was not installed by CKAN. \n Please remove manually before trying again", module);
}
//Exit if any are auto_detected
if (auto_detected_modules.Any()) return Exit.ERROR;

User.RaiseMessage("\nUpgrading modules...\n");
// TODO: These instances all need to go.
ModuleInstaller.GetInstance(ksp, User).Upgrade(to_upgrade,new NetAsyncDownloader(User));
Expand Down
2 changes: 2 additions & 0 deletions CKAN/CmdLine/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public static int Main(string[] args)
return Available(manager.CurrentInstance, user);

case "install":
Scan(manager.CurrentInstance);
return Install((InstallOptions)cmdline.options, manager.CurrentInstance, user);

case "scan":
Expand All @@ -170,6 +171,7 @@ public static int Main(string[] args)
return Remove((RemoveOptions)cmdline.options, manager.CurrentInstance, user);

case "upgrade":
Scan(manager.CurrentInstance);
var upgrade = new Upgrade(user);
return upgrade.RunCommand(manager.CurrentInstance, cmdline.options);

Expand Down
18 changes: 12 additions & 6 deletions CKAN/GUI/Util.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;


namespace CKAN
{
using System.Runtime.InteropServices;
using System.Windows.Forms;

public static class Util
{

public static bool IsLinux
{
get
Expand Down Expand Up @@ -75,12 +76,17 @@ public static void HideConsoleWindow()
ShowWindow(GetConsoleWindow(), 0);
}
}
}
}


namespace CKAN
{
public static class UtilWithoutWinForm
{
public static bool IsInstallable(this GUIMod mod)
{

return !(mod == null || mod.IsAutodetected || mod.IsIncompatible);
}
}

}
}

0 comments on commit 2132b46

Please sign in to comment.