How can I get the name of the command called for usage prompts in Ruby?

前端 未结 4 1510
不思量自难忘°
不思量自难忘° 2020-12-07 14:20

I wrote a nice little Ruby script a while back that I\'m rather fond of. I\'d like to improve its robustness by checking for the proper number of arguments:

         


        
4条回答
  •  天涯浪人
    2020-12-07 15:20

    This isn't quite an answer to your question, but it sounds like you're reinventing a wheel. Look at the optparse library. It lets you define command line switches, arguments, etc, and it'll do all the heavy lifting for you.

提交回复
热议问题