veged/coa

Change interface of .act() callback functions

arikon opened this issue · 3 comments

My proposal it to change API of .act() callbacks from

function(opts, args) {
}

to

function(options) {
   // options = opts + args
}

Motivation

  1. The difference between opts and args in semantical only and only make sense when command is run from the command line

  2. It is hard to explain to develepor what the difference between opts and args when it uses COA API to run command

  3. Division into two different arguments makes sense in case when opts is a hash and args is an array

  4. Compare

    var BEM = require('bem');
    BEM.api.create.block({ tech: ['css', 'js'] }, { names: ['b1', 'b2'] });

    and

    var BEM = require('bem');
    BEM.api.create.block({ names: ['b1', 'b2'], tech: ['css', 'js'] });

/cc @veged

we can just add args to opts but keep second argument for act function for full backward compatibility

@veged Backwards compatibility will broke if there were args and opts with the same name('...') declaration

@arikon yep, but that's some kind "unsemantic" and seems nobody do that