commander-rb / commander

The complete solution for Ruby command-line executables
MIT License
822 stars 74 forks source link

Script ignores small switch #65

Closed Zejnilovic closed 6 years ago

Zejnilovic commented 6 years ago

I have specified small switches, so they would show in help and so I have "power" over them. But when I try to use myscript run -t alfa, the type doesnt set. It works for -i and -m just fine. But with type I need to write --type

#!/usr/bin/env ruby

require 'rubygems'
require 'commander/import'

program :name, 'MyScript'
program :version, '0.1.0'
program :description, "Script execution"

command :run do |c|
  c.syntax = 'test_runner run [options]'
  c.description = 'Run test script or a set of test scripts'
  c.option('-t STRING', '--type STRING', String, 'Type')
  c.option('-i STRING', '--input STRING', String, 'Path')
  c.option('-m STRING', '--max_depth STRING', String, 'Maximal depth')
  c.action do |args, options|
    options.default max_depth: '0'
    say "Params are: #{options.type}, #{options.input}, #{options.max_depth}"
  end
end

c.option('-t', '--type STRING', String Does not work either.

Zejnilovic commented 6 years ago

On my way on the subway I realized the -t is small switch for --trace. Moving on.

ggilder commented 6 years ago

That's right, it is a global switch that Commander defines. If that's an important feature you'd like to have, there's a similar issue https://github.com/commander-rb/commander/issues/64 about disabling the -v / --version predefined switch — you could create a patch if you're interested.