Skip to content

Commit

Permalink
Fixing logic error
Browse files Browse the repository at this point in the history
Fixes #5920
  • Loading branch information
ycombinator authored and epixa committed Jan 16, 2016
1 parent 9a0be4e commit f80ef70
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/cli/plugin/setting_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ export default function createSettingParser(options) {
return 'https://download.elastic.co/' + settings.organization + '/' + settings.package + '/' + filename;
}

function areMultipleOptionsChosen(options, choices) {
let numChosen = 0;
choices.forEach(function (choice) {
if (options[choice]) {
++numChosen;
}
});
return (numChosen > 1);
}

function parse() {
let parts;
let settings = {
Expand Down Expand Up @@ -88,7 +98,7 @@ export default function createSettingParser(options) {
settings.action = 'list';
}

if (!settings.action || (options.install && options.remove && options.list)) {
if (!settings.action || areMultipleOptionsChosen(options, [ 'install', 'remove', 'list' ])) {
throw new Error('Please specify either --install, --remove, or --list.');
}

Expand Down

0 comments on commit f80ef70

Please sign in to comment.