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

Keys from config files should be converted to symbols #2

Open
vStone opened this issue Sep 24, 2019 · 0 comments · May be fixed by #3
Open

Keys from config files should be converted to symbols #2

vStone opened this issue Sep 24, 2019 · 0 comments · May be fixed by #3

Comments

@vStone
Copy link

vStone commented Sep 24, 2019

When using the configuration file like the examples you end up with a string and symbol key.

#!/usr/bin/env ruby
require 'cl'

module Example
  class Foo < ::Cl::Cmd
    opt '--foobar STRING', default: 'Foobar default value'
    def run
      puts opts.to_yaml()
    end
  end
end

File.open('.example.yml', 'w') do |file|
  file.puts <<~yml
  ---
  foo:
    foobar: 'Foobar from Yaml'
  yml
end

puts "Default options used"
Cl.new('example').run(['foo'])
puts "--------------------"
puts "Command line used"
Cl.new('example').run(['foo', '--foobar', 'From command line'])
puts "--------------------"

outputs

Default options used
---
foobar: Foobar from Yaml
:foobar: Foobar default value
--------------------
Command line used
---
foobar: Foobar from Yaml
:foobar: From command line
--------------------
@vStone vStone linked a pull request Sep 25, 2019 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant