From 2bdfb44e3d519f818151c4013bb83cf607ccb342 Mon Sep 17 00:00:00 2001 From: David Middlecamp Date: Mon, 28 Apr 2014 12:37:47 -0500 Subject: [PATCH] adding optional --saveTo argument for specifying cloud compile binary path, should fix #3 --- js/commands/CloudCommands.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/js/commands/CloudCommands.js b/js/commands/CloudCommands.js index 530502c..55d410a 100644 --- a/js/commands/CloudCommands.js +++ b/js/commands/CloudCommands.js @@ -71,6 +71,20 @@ CloudCommand.prototype = extend(BaseCommand.prototype, { this.addOption("logout", this.logout.bind(this), "Logs out your session and clears your saved access token"); }, + checkArguments: function (args) { + this.options = this.options || {}; + + if (!this.options.saveBinaryPath && (utilities.contains(args, "--saveTo"))) { + var idx = utilities.indexOf(args, "--saveTo"); + if ((idx + 1) < args.length) { + this.options.saveBinaryPath = args[idx + 1]; + } + else { + console.log("Please specify a file path when using --saveTo"); + } + } + }, + claimCore: function (coreid) { if (!coreid) { console.error("Please specify a coreid"); @@ -207,6 +221,8 @@ CloudCommand.prototype = extend(BaseCommand.prototype, { return; } + this.checkArguments(arguments); + var files = this._getFilesAtPath(filePath); if (!files) { return; @@ -222,6 +238,7 @@ CloudCommand.prototype = extend(BaseCommand.prototype, { } + var that = this; var api = new ApiClient(settings.apiUrl, settings.access_token); if (!api.ready()) { return; @@ -234,6 +251,12 @@ CloudCommand.prototype = extend(BaseCommand.prototype, { //download function(resp) { if (resp && resp.binary_url) { + + if (that.options.saveBinaryPath) { + filename = that.options.saveBinaryPath; + //console.log("Saving binary to " + filename); + } + return api.downloadBinary(resp.binary_url, filename); } else {