1

I started paying around with Crystal lang, I want to use OptionParser to show a help text, however -h will be interpred by Crystal instead of OptionParser

I am using the example from https://crystal-lang.org/api/0.18.7/OptionParser.html

and calling the app myAppl with:

crystal src/myAppl.cr --help

This shows Crystal help. Now, if I compile the app then it shows the help text I wrote OptionParser

What I am doing wrong?

Snake Sanders
  • 2,641
  • 2
  • 31
  • 42
  • 2
    https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean-also-known-as-bare-double-dash – halfelf Dec 17 '18 at 02:29

1 Answers1

5

Have a look at the first line of that help output:

Usage: crystal run [options] [programfile] [--] [arguments]

That -- is what allows you to force an argument to be passed to the compiled program rather than being used by the compiler. So following your example:

crystal src/myApp1.cr -- --help

Of course if you compile your program you can just pass it directly to the resulting binary:

crystal build src/myApp1.cr
./myApp1 --help
Jonne Haß
  • 4,792
  • 18
  • 30