Class: Commander::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/datapimp/cli/01_extensions.rb

Defined Under Namespace

Classes: Options

Instance Method Summary collapse

Instance Method Details

#action(*args, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/datapimp/cli/01_extensions.rb', line 2

def action(*args, &block)

  wrapper = lambda do |a, options|
    if options.config
      read = Pathname(options.config).read
      json = JSON.parse(read)

      Datapimp.config.apply_all(json)
    end

    Datapimp.config.apply_all(options.to_hash)

    block.call(a, options)
  end

  send(:when_called, *args, &wrapper)
end