private bool ProcessCommandLineArguments(int cmdId, IReadOnlyList <string> args) { var index = cmdId - 1; if (index < 0 || index > _menuItems.Count - 1) { PrintInvalidInputWarning(); return(false); } var menuItem = _menuItems[index]; var options = menuItem.Options; index = 1; var values = new MenuCallValues(); if (options.Count != args.Count - 1) { PrintInvalidInputWarning(); return(false); } foreach (var option in options) { try { var value = option.AsObject(args[index++]); values.AddValue(option.ShortForm, value); } catch (InvalidMenuOptionValueException) { PrintInvalidInputWarning(); return(false); } } try { menuItem.Handler(values); } catch (Exception e) { PrintErrorDuringExecution(e); PressEnterToContinue(); return(false); } PressEnterToContinue(); return(false); }
public abstract void Handler(MenuCallValues values);
public override void Handler(MenuCallValues values) { Environment.Exit(0); }