all files / lib/ cli.js

100% Statements 11/11
100% Branches 6/6
100% Functions 2/2
100% Lines 11/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                            
var bag              = require('bagofcli');
var SwaggyJenkinsCli = require('./swaggyjenkinscli');
 
function _responseToDefinition(inputPath) {
 
  var lastArg = arguments[arguments.length - 1];
  var apiType = lastArg.parent.apiType || 'remote-access';
 
  var opts = {
    inputPath: inputPath,
    reporter: lastArg.reporter ? lastArg.reporter.split(',') : ['console'],
    outFile: lastArg.outFile || 'definitions.yml'
  };
 
  new SwaggyJenkinsCli(apiType).responseToDefinition(opts, bag.exit);
}
 
/**
 * Execute Swaggy Jenkins CLI.
 */
function exec() {
 
  var actions = {
    commands: {
      response2definition: { action: _responseToDefinition }
    }
  };
 
  bag.command(__dirname, actions);
}
 
exports.exec = exec;