aboutsummaryrefslogtreecommitdiffhomepage
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/actions.js5
-rwxr-xr-xcli/surfer.js1
2 files changed, 4 insertions, 2 deletions
diff --git a/cli/actions.js b/cli/actions.js
index 592d809..00ffb6f 100644
--- a/cli/actions.js
+++ b/cli/actions.js
@@ -46,7 +46,7 @@ function login(server) {
46 config.set('server', server); 46 config.set('server', server);
47} 47}
48 48
49function put(filePath, otherFilePaths) { 49function put(filePath, otherFilePaths, options) {
50 checkConfig(); 50 checkConfig();
51 51
52 var files = collectFiles([ filePath ].concat(otherFilePaths)); 52 var files = collectFiles([ filePath ].concat(otherFilePaths));
@@ -54,7 +54,7 @@ function put(filePath, otherFilePaths) {
54 async.eachSeries(files, function (file, callback) { 54 async.eachSeries(files, function (file, callback) {
55 var relativeFilePath = path.resolve(file).slice(process.cwd().length + 1); 55 var relativeFilePath = path.resolve(file).slice(process.cwd().length + 1);
56 56
57 console.log('Uploading file %s', relativeFilePath.cyan); 57 console.log('Uploading file %s -> %s', relativeFilePath.cyan, ((options.destination ? options.destination : '') + '/' + relativeFilePath).cyan);
58 58
59 superagent.put(config.server() + API + relativeFilePath).attach('file', file).end(callback); 59 superagent.put(config.server() + API + relativeFilePath).attach('file', file).end(callback);
60 }, function (error) { 60 }, function (error) {
@@ -90,6 +90,7 @@ function del(filePath) {
90 90
91 var relativeFilePath = path.resolve(filePath).slice(process.cwd().length + 1); 91 var relativeFilePath = path.resolve(filePath).slice(process.cwd().length + 1);
92 superagent.del(config.server() + API + relativeFilePath).end(function (error, result) { 92 superagent.del(config.server() + API + relativeFilePath).end(function (error, result) {
93 if (error.status === 404) return console.log('No such file or directory');
93 if (error) return console.log('Failed', result ? result.body : error); 94 if (error) return console.log('Failed', result ? result.body : error);
94 console.log('Success', result.body); 95 console.log('Success', result.body);
95 }); 96 });
diff --git a/cli/surfer.js b/cli/surfer.js
index d906d62..fbc95b6 100755
--- a/cli/surfer.js
+++ b/cli/surfer.js
@@ -15,6 +15,7 @@ program.command('login')
15 .action(actions.login); 15 .action(actions.login);
16 16
17program.command('put <file> [files...]') 17program.command('put <file> [files...]')
18 .option('-d --destination <folder>', 'Destination folder. This is prepended to the relative <file> path')
18 .description('Put a file') 19 .description('Put a file')
19 .action(actions.put); 20 .action(actions.put);
20 21