public override int Handle(GameInstanceManager manager, IUser user) { int exitCode = base.Handle(manager, user); if (exitCode == Exit.OK) { // User provided game instance if (Gamedir != null && Instance != null) { user.RaiseMessage("--instance and --gamedir can't be specified at the same time"); return(Exit.BADOPT); } try { if (!string.IsNullOrEmpty(Instance)) { // Set a game directory by its alias. manager.SetCurrentInstance(Instance); } else if (!string.IsNullOrEmpty(Gamedir)) { // Set a game directory by its path manager.SetCurrentInstanceByPath(Gamedir); } } catch (NotKSPDirKraken k) { user.RaiseMessage("Sorry, {0} does not appear to be a game instance", k.path); return(Exit.BADOPT); } catch (InvalidKSPInstanceKraken k) { user.RaiseMessage("Invalid game instance specified \"{0}\", use '--gamedir' to specify by path, or 'instance list' to see known game instances", k.instance); return(Exit.BADOPT); } } return(exitCode); }