Esempio n. 1
0
        internal static void HandleModAction(IEnumerable <string> arguments)
        {
            if (arguments.Count() == 0)
            {
                CommandHandler.ListOptions <ModActions>();
                return;
            }

            ModActions?action = CommandHandler.ParseCommandOption <ModActions>(arguments.First());

            if (action == null)
            {
                action = ModActions.Help;
            }

            IEnumerable <string> mods = arguments.Skip(1);

            if (mods.Count() == 0)
            {
                Modifi.DefaultLogger.Error("No mods to work with. Specify some in the format domain:modid.");
                return;
            }

            Pack pack = Modifi.DefaultPack;

            foreach (string mod in mods)
            {
                string  domainName = ModHelper.GetDomainName(mod);
                IDomain handler    = pack.GetDomain(domainName);

                if (handler == null || !(handler is IDomain))
                {
                    Modifi.DefaultLogger.Error("No domain handler found for {0}. Aborting.", domainName);
                    return;
                }

                string modIdentifier = ModHelper.GetModIdentifier(mod);
                string modVersion    = ModHelper.GetModVersion(mod);

                switch (action)
                {
                case ModActions.Add:
                    HandleModAdd(handler, modIdentifier, modVersion);
                    break;

                case ModActions.Remove:
                    HandleModRemove(handler, modIdentifier);
                    break;

                case ModActions.Info:
                    HandleModInformation(handler, modIdentifier, modVersion);
                    break;

                case ModActions.Versions:
                    HandleModVersions(handler, modIdentifier);
                    break;

                case ModActions.Download:
                    HandleModDownload(handler, modIdentifier, modVersion);
                    break;

                case ModActions.Help:
                default:
                    CommandHandler.ListOptions <ModActions>();
                    break;
                }
            }
        }