Skip to content
This repository has been archived by the owner. It is now read-only.
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

readme.md

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

About

Helper for simplified args4j parsing

Resources

License

Packages

No packages published
You can’t perform that action at this time.