private void Parse(string[] args) { Action <Options, string> optionHandler = null; Action <Options> flagHandler = null; foreach (var arg in args) { if (OptionHandlers.TryGetValue(arg, out var thisOptionHandler)) { optionHandler = thisOptionHandler; continue; } if (FlagHandlers.TryGetValue(arg, out var thisFlagHandler)) { flagHandler = thisFlagHandler; continue; } if (optionHandler == null && flagHandler == null) { AddFile(this, arg); continue; } optionHandler?.Invoke(this, arg); flagHandler?.Invoke(this); optionHandler = null; flagHandler = null; } }
private void Parse(string[] args) { Action <Options, string> optionHandler = null; foreach (var arg in args) { if (OptionHandlers.TryGetValue(arg, out var thisOptionHandler)) { optionHandler = thisOptionHandler; continue; } if (FlagHandlers.TryGetValue(arg, out var thisFlagHandler)) { thisFlagHandler.Invoke(this); continue; } if (optionHandler == null) { AddFile(this, arg); continue; } optionHandler?.Invoke(this, arg); optionHandler = null; } if (ShowedHelp) { return; } if (optionHandler != null) { throw new ArgumentException($"No option value set for {args.Last()}"); } }