Read commandline with DSL CliBuilder


/ Published in: Groovy
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.