From: Svjatoslav Agejenko Date: Tue, 1 Apr 2025 21:16:51 +0000 (+0300) Subject: Better documentation. X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=5d4703ebde3601f2cf157ab78be3052079e8d274;p=cli-helper.git Better documentation. --- diff --git a/doc/index.org b/doc/index.org index 6fa1f18..2abb164 100644 --- a/doc/index.org +++ b/doc/index.org @@ -1,28 +1,15 @@ :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: @@ -39,23 +26,43 @@ Library provides following general functionalities: - [[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 @@ -79,7 +86,27 @@ Maven pom.xml file snippet: ... #+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: