Module text-io

The text-io artifact

License

License

Categories

Categories

Text-IO User Interface CLI
GroupId

GroupId

org.beryx
ArtifactId

ArtifactId

text-io
Last Version

Last Version

3.4.1
Release Date

Release Date

Type

Type

jar
Description

Description

Module text-io
The text-io artifact
Project URL

Project URL

https://github.com/beryx/text-io
Source Code Management

Source Code Management

https://github.com/beryx/text-io

Download text-io

How to add to project

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

Dependencies

runtime (3)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.8.0-beta4
jline : jline jar 2.14.6
org.beryx : awt-color-factory jar 1.0.1

Project Modules

There are no modules declared in this project.

PRs Welcome License Build Status

Text-IO

Text-IO is a library for creating Java console applications. It can be used in applications that need to read interactive input from the user.

Features

  • supports reading values with various data types.
  • allows masking the input when reading sensitive data.
  • allows selecting a value from a list.
  • allows to specify constraints on the input values (format patterns, value ranges, length constraints etc.).
  • provides different terminal implementations and offers a Service Provider Interface (SPI) for configuring additional text terminals.

By default, Text-IO tries to use text terminals backed by java.io.Console. If no console device is present (which may happen, for example, when running the application in your IDE), a Swing-based terminal is used instead.

Example

TextIO textIO = TextIoFactory.getTextIO();

String user = textIO.newStringInputReader()
        .withDefaultValue("admin")
        .read("Username");

String password = textIO.newStringInputReader()
        .withMinLength(6)
        .withInputMasking(true)
        .read("Password");

int age = textIO.newIntInputReader()
        .withMinVal(13)
        .read("Age");

Month month = textIO.newEnumInputReader(Month.class)
        .read("What month were you born in?");

TextTerminal terminal = textIO.getTextTerminal();
terminal.printf("\nUser %s is %d years old, was born in %s and has the password %s.\n",
        user, age, month, password);

Click on the image below to see the output of the above example in a Swing-based terminal.

You can also use a web-based terminal, which allows you to access your application via a browser, as shown in the image below.

Useful links

Text-IO is available in Maven Central and JCenter.

org.beryx

Beryx

Versions

Version
3.4.1
3.4.0
3.3.0
3.2.1
3.2.0
3.1.4
3.1.3
3.1.2
3.1.0
3.0.0
3.0.0-alpha-3
3.0.0-alpha-2
3.0.0-alpha-1
2.8.0
2.7.3
2.7.2
2.7.1
2.7.0
2.6.1
2.6.0
2.5.0
2.4.0
2.3.0
2.2.0
2.1.1
2.1.0
2.0.0
1.9.0
1.8.0
1.7.2
1.7.1
1.7.0
1.6.0
1.5.0
1.4.0
1.3.1
1.3.0
1.2.0
1.1.0
1.0.0