2using static System.Console;
5 public static class Iko {
7 /// Gets a double value from the user.
9 /// <returns>The double.</returns>
10 /// <param name="text">Prompt</param>
11 /// <param name="validate">A validation function</param>
12 /// <param name="falseText">Text to print if user fails</param>
13 public static double GetDouble(string text, Func<double, bool> validate, string falseText) {
17 if (double.TryParse(ReadLine(), out res) && validate(res)) {
27 /// Gets a double value from the user.
29 /// <returns>The double.</returns>
30 /// <param name="text">Prompt</param>
31 /// <param name="falseText">Text to print if user fails</param>
32 public static double GetDouble(string text, string falseText) {
33 return GetDouble(text, _ => { return true; }, falseText);
37 /// Gets a float value from the user.
39 /// <returns>The double.</returns>
40 /// <param name="text">Prompt</param>
41 /// <param name="validate">A validation function</param>
42 /// <param name="falseText">Text to print if user fails</param>
43 public static float GetFloat(string text, Func<float, bool> validate, string falseText) {
47 if (float.TryParse(ReadLine(), out res) && validate(res)) {
57 /// Gets a float value from the user.
59 /// <returns>The double.</returns>
60 /// <param name="text">Prompt</param>
61 /// <param name="falseText">Text to print if user fails</param>
62 public static float GetFloat(string text, string falseText) {
63 return GetFloat(text, _ => { return true; }, falseText);
67 /// Gets an int value from the user.
69 /// <returns>The double.</returns>
70 /// <param name="text">Prompt</param>
71 /// <param name="validate">A validation function</param>
72 /// <param name="falseText">Text to print if user fails</param>
73 public static int GetInt(string text, Func<int, bool> validate, string falseText) {
77 if (int.TryParse(ReadLine(), out res) && validate(res)) {
87 /// Gets an int value from the user.
89 /// <returns>The double.</returns>
90 /// <param name="text">Prompt</param>
91 /// <param name="falseText">Text to print if user fails</param>
92 public static int GetInt(string text, string falseText) {
93 return GetInt(text, _ => { return true; }, falseText);
97 /// Repeats a given function.
99 /// <param name="f">the function to be repeated</param>
100 public static void Repeat(Action f) {
103 Write("Press Enter to repeat program. Press any other key to quit.");
104 } while (ReadKey().Key == ConsoleKey.Enter);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list