Example #1
0
        private static void ParseParams(List <string> parameters, out string tasks, out bool simulate, out bool auto, out int?timerInterval)
        {
            simulate      = parameters.Remove("/sim");
            auto          = parameters.Remove("/auto");
            timerInterval = CommandTools.ParseOptionAsInt(parameters, "/interval", true);

            if (!auto && timerInterval != null)
            {
                throw new FriendlyMessageException("Setting an interval without turning on automatic repair is useless. Please add the \"/auto\" option.");
            }

            switch (parameters.Count)
            {
            case 0:
                tasks = RepairEngine.TasksDefault;
                break;

            case 1:
                tasks = "";
                string letters = parameters[0];
                foreach (var key in RepairEngine.TasksDict.Keys)
                {
                    if (letters.Contains(key))
                    {
                        tasks  += key;
                        letters = letters.Replace(key, "");
                    }
                }
                if (letters.Length > 0)
                {
                    throw new FriendlyMessageException($"Did not recognize task letter{(letters.Length == 1 ? "" : "s")} '{letters}'. See help.");
                }
                break;

            default:
                throw new FriendlyMessageException("Wrong number of parameters. See help.");
            }
        }