コード例 #1
0
        internal static void Handle(IEnumerable <string> arguments)
        {
            if (arguments.Count() == 0)
            {
                CommandHandler.ListOptions <PackAction>();
                return;
            }

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

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

            Pack    pack;
            ILogger log = Modifi.DefaultLogger;

            switch (action)
            {
            case PackAction.Download:
                DownloadPack();
                break;

            case PackAction.New:
                if (!PackHelper.PackExists())
                {
                    PackHelper.GeneratePackFile().Wait();
                }
                else
                {
                    log.Error("Pack file already exists.");
                }
                break;

            case PackAction.Info:
                try { pack = Modifi.DefaultPack; }
                catch (IOException) {
                    Modifi.DefaultLogger.Error("Error loading pack, make sure one is created with {0}.", "pack init");
                    return;
                }

                Console.ForegroundColor = ConsoleColor.Magenta;
                log.Information("{0:l}", pack.Name);
                log.Information("Built for Minecraft {0:l}", pack.MinecraftVersion);
                log.Information("");
                log.Information("Required Domains:");

                Console.ForegroundColor = ConsoleColor.White;
                foreach (string domain in pack.UseDomains)
                {
                    log.Information(" - {0:l} ({1:l})", domain, Path.Combine(Settings.DomainsDirectory, domain + ".dll"));
                }
                break;

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