Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Give plugins a way to get and set options #11

Closed
nathankleyn opened this issue Sep 22, 2015 · 1 comment
Closed

Give plugins a way to get and set options #11

nathankleyn opened this issue Sep 22, 2015 · 1 comment

Comments

@nathankleyn
Copy link
Contributor

Plugins currently have to use Env#config to get at the options they might need. This is error prone, and will lead almost certainly to fragmentation. We instead should add a new class method for plugins to declare options upfront (serves as documentation) and then provide auto-defined methods to get at those at the instance level:

class TestPlugin < Plugin
  option :foo
  option :bar, default: 'lux'

  def whatever
    puts options[:bar] # => 'lux' (assuming it was not set in the .shanty.yml or on the CLI)
  end
end
@nathankleyn
Copy link
Contributor Author

To set plugin options from the CLI would need a little bit of syntax to prevent them being ambiguous with task options and whatnot. Perhaps something like this would work:

shanty [-o KEY VALUE, ...] task [TASK_OPTION, ...]

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

No branches or pull requests

1 participant