Skip to content

Keys from config files should be converted to symbols #2

Description

@vStone

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
--------------------

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions