easycli4j

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

Лицензия

Лицензия

Категории

Категории

CLI Взаимодействие с пользователем
Группа

Группа

com.github.sviperll
Идентификатор

Идентификатор

easycli4j
Последняя версия

Последняя версия

0.17
Дата

Дата

Тип

Тип

jar
Описание

Описание

easycli4j
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Ссылка на сайт

Ссылка на сайт

https://github.com/sviperll/easycli4j
Система контроля версий

Система контроля версий

https://github.com/sviperll/easycli4j

Скачать easycli4j

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.sviperll/easycli4j/ -->
<dependency>
    <groupId>com.github.sviperll</groupId>
    <artifactId>easycli4j</artifactId>
    <version>0.17</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.sviperll/easycli4j/
implementation 'com.github.sviperll:easycli4j:0.17'
// https://jarcasting.com/artifacts/com.github.sviperll/easycli4j/
implementation ("com.github.sviperll:easycli4j:0.17")
'com.github.sviperll:easycli4j:jar:0.17'
<dependency org="com.github.sviperll" name="easycli4j" rev="0.17">
  <artifact name="easycli4j" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.sviperll', module='easycli4j', version='0.17')
)
libraryDependencies += "com.github.sviperll" % "easycli4j" % "0.17"
[com.github.sviperll/easycli4j "0.17"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
com.github.sviperll : chicory-core jar 0.17

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.11

Модули Проекта

Данный проект не имеет модулей.

Chicory CLI

Chicory CLI is a command line parsing library.

Chicory CLI is part of Chicory.

Licence

Chicory CLI is provided by means of BSD-3 Clause Licence.

Usage

Maven

    <dependency>
        <groupId>com.github.sviperll</groupId>
        <artifactId>easycli4j</artifactId>
        <version>0.18</version>
    </dependency>

Changelog

Since 0.18

  • Switch to chicory version 0.18.

Example

Here is a full Hello world example

    class Hello {

        public static void main(String[] args) {
            Hello hello = new Hello();
            CLISpecification cli = new CLISpecification(System.out);
            cli.add('n', "name", "Your name", CLIHandlers.string(hello.name));
            cli.add("prefix", "Prefix for your name, i. e. Mr, Mrs, Dr, Sir", CLIHandlers.string(hello.prefix));
            try {
                cli.run(args);
                application.run();
            } catch (CLIException ex) {
                System.out.println(ex.getMessage());
                System.out.println("usage: hello [OPTIONS]");
                try {
                    cli.usage();
                } catch (IOException ex1) {
                    ex1.printStackTrace(System.out);
                }
            } catch (IOException ex) {
                ex.printStackTrace(System.out);
            }
        }

        private Property<String> name = new Property<String>(null);
        private Property<String> prefix = new Property<String>("Mr.");

        private void run() {
            System.out.println("Hello " + prefix.get() + " " + name.get());
        }

    }

When you compile it and run like

java -jar hello.jar -n John --prefix=Sir.

You'll get the following

Hello Sir. John

You can get usage-message like this:

java -jar hello.jar -h

You'll get the following answer

Unknown option -h
usage: hello [OPTIONS]
                 -n OPTION      Your name
                --name=OPTION   Your name
                --prefix=OPTION Prefix for your name, i. e. Mr, Mrs, Dr, Sir (default Mr.)

Версии библиотеки

Версия
0.17