Posted By

miceno on 12/13/10


Tagged

commandline groovy


Versions (?)

Read commandline with DSL CliBuilder


 / Published in: Groovy
 

An example of how to configure the CliBuilder to read command line arguments in Groovy.

  1. // An example of how to configure the CliBuilder to read command line arguments in Groovy.
  2.  
  3. def cli = new CliBuilder( usage: 'groovy launcher' )
  4.  
  5. // Option help
  6. cli.h(longOpt: 'help', 'usage information')
  7.  
  8. // Option script
  9. cli.s(argName:'script', longOpt:'script', required: true,
  10. args: 1, 'Script filename')
  11.  
  12. def opt = cli.parse(args)
  13. if (!opt) return
  14. if (opt.h) {
  15. cli.usage()
  16. }

Report this snippet  

You need to login to post a comment.