Moved CLI helper functionality to new dedicated project:
[svjatoslav_commons.git] / src / main / java / eu / svjatoslav / commons / commandline / CLIHelper.java
diff --git a/src/main/java/eu/svjatoslav/commons/commandline/CLIHelper.java b/src/main/java/eu/svjatoslav/commons/commandline/CLIHelper.java
deleted file mode 100755 (executable)
index 597bdec..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Svjatoslav Commons - shared library of common functionality. Author: Svjatoslav Agejenko.
- * This project is released under Creative Commons Zero (CC0) license.
- */
-package eu.svjatoslav.commons.commandline;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-/**
- * Command-line interface helper.
- */
-public class CLIHelper {
-
-    /**
-     * Ask boolean value from user on command-line.
-     *
-     * @param prompt to show to the user
-     * @return <code>true</code> is user answered affirmative.
-     */
-    public static boolean askBoolean(final String prompt) {
-
-        final BufferedReader br = new BufferedReader(new InputStreamReader(
-                System.in));
-
-        while (true)
-            try {
-                System.out.print(prompt);
-
-                String line = br.readLine();
-                if (line != null) {
-                    final String userInput = line.toLowerCase();
-
-                    if ("y".equals(userInput) || "yes".equals(userInput)
-                            || "true".equals(userInput))
-                        return true;
-
-                    if ("n".equals(userInput) || "no".equals(userInput)
-                            || "false".equals(userInput))
-                        return false;
-                }
-                System.out
-                        .println("Invalid input. You shall enter y/yes/true or n/no/false.");
-            } catch (final IOException ioe) {
-                ioe.printStackTrace();
-            }
-    }
-
-    /**
-     * Ask numerical long value from user on command-line.
-     *
-     * @param prompt to show to the user
-     * @return value given by user
-     */
-    public static long askLong(final String prompt) {
-
-        final BufferedReader br = new BufferedReader(new InputStreamReader(
-                System.in));
-
-        while (true) {
-            System.out.print(prompt);
-
-            try {
-                final String userInput = br.readLine();
-
-                try {
-                    return Long.parseLong(userInput);
-                } catch (final NumberFormatException e) {
-                    System.out.println("\nError: You shall enter an integer.");
-                }
-            } catch (final IOException ioe) {
-                ioe.printStackTrace();
-            }
-
-        }
-    }
-
-    /**
-     * Ask string value from user on command-line.
-     *
-     * @param prompt to show to the user
-     * @return value given by the user
-     */
-    public static String askString(final String prompt) {
-
-        final BufferedReader br = new BufferedReader(new InputStreamReader(
-                System.in));
-
-        while (true) {
-            System.out.print(prompt);
-
-            try {
-                return br.readLine();
-            } catch (final IOException ioe) {
-                ioe.printStackTrace();
-            }
-
-        }
-    }
-
-}