shantytown / shanty

Meet Shanty, the project tool orchestrator.
MIT License
4 stars 0 forks source link

Give plugins a way to get and set options #11

Closed nathankleyn closed 9 years ago

nathankleyn commented 9 years ago

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 commented 9 years ago

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, ...]