:PROPERTIES:
:ID: bb4f96cd-458c-495b-a605-313b2e3e28d2
:END:
+#+SETUPFILE: ~/.emacs.d/org-styles/html/darksun.theme
#+TITLE: CLI Helper - library to help implementing commandline interfaces
+#+LANGUAGE: en
+#+LATEX_HEADER: \usepackage[margin=1.0in]{geometry}
+#+LATEX_HEADER: \usepackage{parskip}
+#+LATEX_HEADER: \usepackage[none]{hyphenat}
-* General
-- This program is free software: released under Creative Commons Zero
- (CC0) license
-
-- Program author:
- - Svjatoslav Agejenko
- - Homepage: https://svjatoslav.eu
- - Email: mailto://svjatoslav@svjatoslav.eu
-
-- [[https://www.svjatoslav.eu/projects/][Other software projects hosted at svjatoslav.eu]]
-
-** Source code
-- [[https://www2.svjatoslav.eu/gitweb/?p=cli-helper.git;a=snapshot;h=HEAD;sf=tgz][Download latest snapshot in TAR GZ format]]
-
-- [[https://www2.svjatoslav.eu/gitweb/?p=cli-helper.git;a=summary][Browse Git repository online]]
-
-- Clone Git repository using command:
- : git clone https://www3.svjatoslav.eu/git/cli-helper.git
-
-- See [[https://www3.svjatoslav.eu/projects/cli-helper/apidocs/][JavaDoc]]
+#+OPTIONS: H:20 num:20
+#+OPTIONS: author:nil
* Overview
:PROPERTIES:
- [[id:4fca35e4-fdf1-4675-a36f-6206d6fb72cb][Asking for user input]]
- [[id:46115263-ed3d-4acc-9ec5-523d7acf87b8][Commandline arguments processing]]
+See also: [[https://clig.dev/][Command Line Interface Guidelines]].
+
** Ask for user input
:PROPERTIES:
:ID: 4fca35e4-fdf1-4675-a36f-6206d6fb72cb
:END:
-- askBoolean() :: Asks the user to enter a boolean value (yes/no).
-- askLong() :: Asks the user to enter an integer.
-- askString() :: Asks the user to enter a string.
+The =CLIHelper= provides user-friendly methods to read different data
+types from standard input. It helps validate user input, display
+prompts, handle default values, and enforce optional constraints like
+numeric ranges or string lengths.
-* Alternatives and further reading
+For quick usage, here’s a simple example showing how you might query
+users for a boolean value, an integer, and a string:
-- [[https://clig.dev/][Command Line Interface Guidelines]]
+#+BEGIN_SRC java
+import eu.svjatoslav.commons.cli_helper.CLIHelper;
+
+public class Demo {
+ public static void main(String[] args) {
+ Boolean proceed = CLIHelper.askBoolean("Do you want to proceed?", true);
+ Integer age = CLIHelper.askInteger("Please enter your age:", 18, 0, 120, false);
+ String name = CLIHelper.askString("What is your name?", "Anonymous");
+
+ System.out.println("Proceed: " + proceed);
+ System.out.println("Age: " + age);
+ System.out.println("Name: " + name);
+ }
+}
+#+END_SRC
+
+See [[https://www3.svjatoslav.eu/projects/cli-helper/apidocs/eu/svjatoslav/commons/cli_helper/CLIHelper.html][Javadoc]] for complete API reference.
* Getting the library
-Instructions to embed svjatoslav-commons library in your project:
+Follow instructions to embed *cli-helper* library in your project.
-Maven pom.xml file snippet:
+Add following snippets to your project *pom.xml* file:
#+BEGIN_SRC xml
<dependencies>
...
</repositories>
#+END_SRC
-* TODO:
+* Getting the source code
+- This program is free software: released under Creative Commons Zero
+ (CC0) license
+
+- Program author:
+ - Svjatoslav Agejenko
+ - Homepage: https://svjatoslav.eu
+ - Email: mailto://svjatoslav@svjatoslav.eu
+
+- [[https://www.svjatoslav.eu/projects/][Other software projects hosted at svjatoslav.eu]]
+
+** Source code
+- [[https://www2.svjatoslav.eu/gitweb/?p=cli-helper.git;a=snapshot;h=HEAD;sf=tgz][Download latest snapshot in TAR GZ format]]
+
+- [[https://www2.svjatoslav.eu/gitweb/?p=cli-helper.git;a=summary][Browse Git repository online]]
+
+- Clone Git repository using command:
+ : git clone https://www3.svjatoslav.eu/git/cli-helper.git
+
+- See [[https://www3.svjatoslav.eu/projects/cli-helper/apidocs/][JavaDoc]]
+* TODO
List of improvement suggestions: