Skip to content

Instantly share code, notes, and snippets.

@gkowalski
Created May 17, 2013 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gkowalski/5599595 to your computer and use it in GitHub Desktop.
Save gkowalski/5599595 to your computer and use it in GitHub Desktop.
Example of Handling command line parameters in a groovy script
println "Started Groovy Script"
println "All args Received : "
println args
className = getClass().simpleName
def cli = new CliBuilder(usage: "groovy ${className}.groovy -h HOSTNAME -u USERNAME -p PASSWORD -pt PROCESSTYPEURI -a INPUTANALYTELIMSID")
cli.u(argName:'username', longOpt:'username', required:true, args:1, 'LIMS username (Required)')
cli.p(argName:'password', longOpt:'password', required:true, args:1, 'LIMS password (Required)')
cli.pt(argName:'processTypeURI', longOpt:'processTypeURI', required:true, args:1, 'The Uri of the process used in process (Required)')
def opt = cli.parse(args)
if (!opt) {
println "Aborted Groovy Script"
System.exit(-1)
}
hostname = opt.h
username = opt.u
password = opt.p
processTypeURI = opt.pt
inputAnalyeLIMSID = opt.a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment