• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

groovy with apache cli - incorrect parsing

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to write a command line script in groovy and here's the first attempt (test of course ;]):

When I invoke the script with 'groovy bs.groovy' the following message is displayed:


error: Missing required option: v
usage: usage TODO
-h,--help usage information
-v,--version <version> global version settings
No options entered!
usage: usage TODO
-h,--help usage information
-v,--version <version> global version settings



Is it possible to catch the situation where no options are entered? In such case I'd just like to display the usage info.

Also when the script is invoked with 'groovy bs.groovy -h' the same error messages is displayed. How to prevent parsing when 'help' option is present? In such case I'd like to display the usage info (ignoring the rest of options) and exit.

Any help would be greatly appreciated.
 
reply
    Bookmark Topic Watch Topic
  • New Topic