public bool Parse(string optionName, StringIterator strings) { if (optionName != "--autonext") { return(false); } string val = strings.GetNext(); if (val == null) { throw new ArgumentException("--autonext should be followed by the interval in seconds"); } int interval; if (!int.TryParse(val, out interval)) { throw new ArgumentException("Can't part number of seconds for the --autonext parameter"); } mOptions.AutoNext = interval; return(true); }
public void Load(string[] args) { foreach (IOptionController option in mOptions) { option.ResetToDefault(); } DeleteAfterWatch = false; SortOrder = SortOrder.Default; Extensions = new List <string>(new string[] { "*.mkv", "*.avi", "*.mp4", "*.webm", "*.wmv", "*.vob", "*.ts", "*.mpg", "*.m4v" }); StringIterator strings = new StringIterator(args); string current = strings.GetNext(); while (current != null) { if (!parseOption(current, strings)) { switch (current) { case "--filter": current = strings.GetNext(); if (current == null) { throw new ArgumentException("--filter should be followed by filter string"); } Filter = new SimpleMatchFilter(current); break; case "--rfilter": current = strings.GetNext(); if (current == null) { throw new ArgumentException("--rfilter should be followed by filter string"); } Filter = new RegexpMatchFilter(current); break; case "--delete": DeleteAfterWatch = true; break; case "--random": SortOrder = SortOrder.Random; break; case "--random-continue": SortOrder = SortOrder.RandomContinue; break; case "--sort-by-name": SortOrder = SortOrder.ByName; break; case "--extensions": current = strings.GetNext(); if (current == null) { throw new ArgumentException("--extensions should be followed by list of extension separated by ;"); } string[] extensions = current.Split(new char[] { ';' }); Extensions = new List <string>(extensions); break; default: throw new NotSupportedException("Unknown argument:" + current); } } current = strings.GetNext(); } }