Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undocumented change in 2.6 seems to prevent multiple keys for same flag pointing to default value #148

Closed
smackesey opened this issue Jun 25, 2013 · 5 comments

Comments

@smackesey
Copy link

I have a command declared like this:

desc 'Compute a matrix and save to the desktop'
arg_name 'matrix'
command :compute do |c|

  c.desc 'format'
  c.default_value 'csv'
  c.flag :f, :format

  c.desc 'path to file'
  c.default_value File.join(conf.compute_output_dir, "#{Time.now.strftime("%y%m%d%H%M%S")}")
  c.flag :p, :path

  c.action(&method(:compute))
end

In 2.5.6, inside the called method compute, the options hash would contain pairs of entries for both :f and :format and :p and :path that pointed to the default values. In 2.6, the long form of the option is not being included in the Hash-- it has only :f and :p keys. If I switch the order of the symbols in the flag list, then it is only :format and :path that show up-- so it looks like only the first name for the flag is recorded. This is happening either with or without the subcommand_option_handling :normal directive introduced in 2.6.

@shantipants
Copy link

I've run into the same issue. fc56475 Seems to be a likely culprit, but I don't really have time to dig into it. Hope this helps!

@mckern
Copy link

mckern commented Jun 26, 2013

+1

@davetron5000
Copy link
Owner

Yeah, this is subtle. Since I moved to OptionParser, I just had the block of on set the value in the hashes for all aliases in symbol and string form. The defaults aren't set that way. Looking into it…

@davetron5000
Copy link
Owner

Once Travis verifies the build is working, I'll release 2.6.1 and post about it here. Sorry for the regression!

Does anyone on this issue have open source apps using GLI? I could definitely use a larger testbed…

@davetron5000
Copy link
Owner

2.6.1 is on RubyGems - please re-open if it didn't fix it and sorry again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants