Skip to content

read options from yaml file instead of passed options #413

@netbe

Description

@netbe

Hi,

I did manage to have a subclass of Thor read a config YAML file doing something like this:

  private

  def options
    original_options = super
    return original_options unless File.exists?(".babelish")
    defaults = ::YAML.load_file(".babelish") || {}
    Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
  end

this works well until you use required options and then the configuration is not reqd. So i guess my coed should be put elsewhere before required options are checked. Any advice where that may be?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions