sviperll-cli

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

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.github.sviperll
ArtifactId

ArtifactId

sviperll-cli
Last Version

Last Version

0.4.2
Release Date

Release Date

Type

Type

jar
Description

Description

sviperll-cli
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Project URL

Project URL

http://maven.apache.org
Source Code Management

Source Code Management

https://github.com/sviperll/sviperll-cli

Download sviperll-cli

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
com.github.sviperll : sviperll-common jar 1.0.3

test (1)

Group / Artifact Type Version
junit : junit jar 3.8.1

Project Modules

There are no modules declared in this project.

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.)

Versions

Version
0.4.2
0.4.1
0.4
0.2