args4j-helpers


License

License

Categories

Categories

args4j User Interface CLI
GroupId

GroupId

com.bizo
ArtifactId

ArtifactId

args4j-helpers_2.10
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

args4j-helpers
args4j-helpers
Project URL

Project URL

https://github.com/ogrodnek/args4j-helpers
Project Organization

Project Organization

com.bizo
Source Code Management

Source Code Management

https://github.com/ogrodnek/args4j-helpers

Download args4j-helpers_2.10

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.10.3
args4j : args4j jar 2.0.26

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
com.novocode : junit-interface jar 0.10-M4

Project Modules

There are no modules declared in this project.

args4j-helpers

Build Status

Simple helper for command-line parsing using args4j.

Args4j is a fantastic parsing library, but there's typically a lot of boilerplate for dealing with printing usage and dealing with parse errors.

This library encapsulates typical option parsing error handling:

  • If help (provided via OptionWithHelp base trait bound to --help and -h) is requested, print usage information to stderr, exit with code 0.
  • If a required option is missing (required=true), print usage information to stderr, exit with code 1 (unless help was requested).

Usage

Define your options class normally, extending OptionsWithHelp

class MyOptions extends OptionsWithHelp {
  @Option(name="--blah", aliases=Array("-b"), usage="some val", metaVar="BLAH")
  var blah: Int = 0
}

retrieving/parsing becomes a single line

import OptionHelper.optionsOrExit

def main(args: Array[String]) {
  val options = optionsOrExit(args, new MyOptions)
  
  println(s"blah is ${options.blah}")
}

License

Apache 2 License

Versions

Version
1.0.0