denisdefreyne / cri

A tool for building commandline applications
MIT License
120 stars 19 forks source link

Handle options before validating arguments #78

Closed denisdefreyne closed 6 years ago

denisdefreyne commented 6 years ago

This lets Cri handle options before validating arguments, so that a command that has multiple parameters can still take a -h option with zero arguments, provided that the -h option handler exits. For example:

        param :foo

        option :h, :help, 'show help' do
          puts 'I am helping I swear'
          exit 0
        end

… when given -h, will print I am helping I swear, without raising an exception.

This also changes parser.arguments to parser.gen_argument_list, which I believe makes it more clear that it is not a mere accessor.