Zandero

command line parsing utilities

License

License

GroupId

GroupId

com.zandero
ArtifactId

ArtifactId

cmd
Last Version

Last Version

1.3
Release Date

Release Date

Type

Type

jar
Description

Description

Zandero
command line parsing utilities
Source Code Management

Source Code Management

https://github.com/Zandero/cmd

Download cmd

How to add to project

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

Dependencies

compile (4)

Group / Artifact Type Version
com.zandero : utils jar [1.2,)
com.zandero : utils.extra jar [1.2,)
com.zandero : settings jar [1.2.1,)
org.slf4j : slf4j-api jar 2.0.0-alpha1

test (5)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar [1.1.7,)
org.junit.jupiter : junit-jupiter-engine jar [5.6.0,)
org.junit.jupiter : junit-jupiter-api jar [5.6.0,)
net.trajano.commons : commons-testing jar [2.1.0,)
org.mockito : mockito-all jar [1.10.19,)

Project Modules

There are no modules declared in this project.

command line parser

Command line parsing utility, that converts a given command line to a name, value Map

Example

java -jar MyApp.jar -t 10 -p raw

Will produce a setting map:

Map<String, Object> settings = new HashMap<>();
settings.put("t", 10);
settings.put("p", "raw");`

Setup

<dependency>      
     <groupId>com.zandero</groupId>      
     <artifactId>cmd</artifactId>      
     <version>1.3</version>      
</dependency>

Usage

// define command arguments
CommandOption all = new BoolOption("a")
	.longCommand("all")
	.setting("getAll");

CommandOption file = new StringOption("f")
	.longCommand("file")
	.setting("fileName");

CommandOption size = new IntOption("s")
	.longCommand("size")
	.setting("fileSize");

// create builder
CommandBuilder builder = new CommandBuilder();
builder.add(all);
builder.add(file);
builder.add(size);

// create parser
CommandLineParser parser = new CommandLineParser(builder);
// use parser to parse input arguments
String[] args = new String[]{"-a", "--file", "/this.file", "-s", "100");
    
Settings out = parser.parse(args);
    
int size = out.get("fileSize");
boolean getAll = out.get("getAll");
Stirng fileName = out.get("fileName");
com.zandero

Zandero

A collection of useful utilities, extensions and wrappers

Versions

Version
1.3
1.2.2
1.2.1
1.2
1.0