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,521
  • 16
  • 29

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
  • 14,024
  • 9
  • 51
  • 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
  • 66,324
  • 14
  • 138
  • 158
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
  • 33,645
  • 23
  • 135
  • 217