Skip to content

Commit

Permalink
Adding first draft option
Browse files Browse the repository at this point in the history
  • Loading branch information
elmasse committed Nov 18, 2014
1 parent f7a12f5 commit 04407f5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
'use strict';

var cocktail = require('cocktail');
var cocktail = require('cocktail');

var senchaCmd = require('./cmd/sencha');
var listCmd = require('./cmd/list');
var useCmd = require('./cmd/use');
var noOpCmd = require('./cmd/noop.js');

//TODO: Review this, maybe using nopts
var CMD_OPTIONS = {
'use' : [noOpCmd],
'noop' : [noOpCmd],
'use' : [useCmd],
'list' : [listCmd]
};

Expand Down
42 changes: 42 additions & 0 deletions src/cmd/use.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

var cocktail = require('cocktail');
var path = require('path');
var fs = require('fs');

var withSpawn = require('./withSpawn');
var withCmdVersions = require('./withCmdVersions');

cocktail.mix({
'@exports': module,
'@as': 'class',

'@requires': [
'getArgs'
],

'@traits': [
withSpawn,
withCmdVersions
],

resolveCmd: function () {
var fromCfg = this.retrieveFromArgs(),
cmd = 'sencha';

if (fromCfg && fs.existsSync(fromCfg)) {
cmd = fromCfg;
}

return cmd;
},

retrieveFromArgs: function () {
var args = this.getArgs().splice(0,2),
bin = this.retrieveCmdBinPath();

return path.join(bin, args.pop(), 'sencha');

}

});

0 comments on commit 04407f5

Please sign in to comment.