Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package trial
- // These are some basic imports for Args4j
- import org.kohsuke.args4j.CmdLineException
- import org.kohsuke.args4j.CmdLineParser
- import org.kohsuke.args4j.{ Option => Args4jOption, Argument } // => renames Option class for clarity
- object helper {
- class Options {
- /*
- * This class is simply a container that holds our options
- */
- @Argument(required = false, metaVar = "INPUT1", usage = "The first ADAM file to compare", index = 0)
- val input1Path: String = null
- @Args4jOption(name = "--help", aliases = Array("-h"), usage = "show this message")
- var help = false
- @Args4jOption(name = "--count", aliases = Array("-c"), depends=Array("INPUT1"), usage = "some val", metaVar = "BLAH")
- var count: Int = 0
- @Args4jOption(name = "--taco", aliases = Array("-t"), usage = "Required Test Taco", metaVar = "TACO")
- var taco = false
- }
- def main(args: Array[String]) {
- val options = new Options // Defines an object from our Options class (could be named anything)
- val parser = new CmdLineParser(options) // Define a parser object from the options objects
- println("Test Print")
- try {
- parser.parseArgument(args: _*) // This line culls the arguments.
- if (options.count != 0) println("You've chosen a new # of Tacos: " + options.count)
- if (options.taco) println("You've opted for TACOS! Taco=" + options.taco)
- if (options.help) {
- parser.printUsage(System.err)
- //println("You Wanted help!")
- sys.exit(0)
- }
- } catch {
- case e: CmdLineException => {
- println("Option Entered Incorrectly by User: ")
- System.err.println(e.getMessage)
- parser.printUsage(System.err)
- sys.exit(1)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement