0

I've seen a number of option parsing libraries out there for ruby, but they all come with weird constraints about them.

'executable' gem claims that all command line binaries must have a syntax "binary

'micro-optparse' can't handle trailing list of filenames and requires you have defaults for all non-boolean commands. Strange.

Some other one I used made it impossible to run a command without arguments.

And so on and so on. And I don't want to parse ARGV myself.

Is there anything close to a specification or standard for command line options and arguments? And then what option parsing library complies to that standard?

ulver
  • 1,461
  • 16
  • 28

3 Answers3

2

Do you know about optparse? It's included in stdlib - as standard as it gets.

But there is no unix standard set in stone as to parsing command-line parameters.

You should define your requirements more clearly and then choose a library that suits them.

Leonid Shevtsov
  • 13,666
  • 9
  • 49
  • 82
1

There's no standard I have ever heard of, but AFAIR Trollop was started out of the frustration with the other command line parsers.

Michael Kohl
  • 64,924
  • 11
  • 136
  • 155
0

+1 for Michael Kohl's mention of Trollop. Trollop makes it very easy to write command line options that conform to the gnu style.

I wrote a simple self-contained example in How do I make a Ruby script using Trollop for command line parsing?.

Community
  • 1
  • 1
fearless_fool
  • 31,575
  • 23
  • 126
  • 205