Options_parser_again
When I discovered the gem optimist
.. I thought I struck gold. Then I came across optimist_xl
.
I started working on my own options parser.. then found rationalist
. It is almost exactly what I wanted to write.
Only difference is that I wanted this behaviour:
opts = Parse::Args {
:namE
:password_x!, {default: 'secret'}
:age, :int, {range: (1..100)}
}
# I defined both the long and short name in the key.
# all lowercase => first char is the short name
# end with _char => char is the short name
# capital char => capital char is the short name
# end with exclamation point => obligatory argument
# (pointless mixing with a default value as in my example)
# --name -e
# --password -x
# --age -a
Rationalist has the alias
method instead..
alias: {name: :e, password: :x, age: :a}