/// <summary> ///Prints a list of the items in collection of T and asks user to choose one of the items. ///Returns the T chosen. /// </summary> /// <param name="items">Collection of T. </param> /// <param name="items">Collection of T. </param> /// <param name="keyFactory">How to get the key</param> /// <param name="lowestNr">Lowest accepted number</param> /// <param name="highestNumber">Highest accepted number</param> /// <param name="errorMessage">Displayed if input does not parse to in</param> /// <param name="clearScreen">Should screen be cleared before asking for input? Default is true.</param> /// <returns>The chosen item of type T</returns> public static T ChooseFromList <T>(IEnumerable <T> items, Func <T, string> keyFactory, ViewStyle style = null) => Choose.ChooseFromList(items, keyFactory, style);
/// <summary> /// Stops execution and asks user for input. /// </summary> /// <param name="message">Message displayed on screen when asking for input</param> /// <param name="clearScreen">Should screen be cleared before asking for input?</param> /// <returns>the input as string</returns> public static string ChooseString(string message, bool clearScreen = false) => Choose.ChooseString();
/// <summary> /// Prints a list and asks user to choose one of the items. If input doesnt parse to int the user will be asked again. /// This overload clears screen before printing. /// </summary> /// <param name="message">Message displayed on screen when asking for input</param> /// <param name="errorMessage">Displayed if input does not parse to in</param> /// <param name="clearScreen">Should screen be cleared before asking for input?</param> /// <returns>the parsed input as int</returns> public static int ChooseFromList(params string[] menuItems) { return(Choose.ChooseFromList(null, menuItems)); }
/// <summary> /// Stops execution and asks user for a number. If input doesnt parse to int the user will be asked again. /// </summary> /// <param name="message">Message displayed on screen when asking for input</param> /// <param name="lowestNr">Lowest accepted number</param> /// <param name="highestNumber">Highest accepted number</param> /// <param name="errorMessage">Displayed if input does not parse to in</param> /// <param name="clearScreen">Should screen be cleared before asking for input?</param> /// <param name="modifier">Modifies the result. Used to handle zero based indexes</param> /// <returns>the parsed input as int</returns> public static int ChooseInt(string promptMessage, int lowestNr = 1, int highestNumber = 9999999, int modifier = 0) => Choose.ChooseInt(promptMessage, lowestNr, highestNumber);