aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohannes Zellner <johannes@cloudron.io>2017-02-09 13:16:41 +0100
committerJohannes Zellner <johannes@cloudron.io>2017-02-09 13:16:41 +0100
commit15397f71b86c50f306e5116f557c9f290b348b1a (patch)
treedb2eb2b15bb8bb12174221c203f54a964791dea8
parent8fa082298cfbfd96eaa029d6e60ff5fd8ce65252 (diff)
downloadSurfer-15397f71b86c50f306e5116f557c9f290b348b1a.tar.gz
Surfer-15397f71b86c50f306e5116f557c9f290b348b1a.tar.zst
Surfer-15397f71b86c50f306e5116f557c9f290b348b1a.zip
Add cli logout command
-rw-r--r--cli/actions.js18
-rwxr-xr-xcli/surfer.js4
2 files changed, 22 insertions, 0 deletions
diff --git a/cli/actions.js b/cli/actions.js
index 45656a6..065e700 100644
--- a/cli/actions.js
+++ b/cli/actions.js
@@ -1,6 +1,7 @@
1'use strict'; 1'use strict';
2 2
3exports.login = login; 3exports.login = login;
4exports.logout = logout;
4exports.put = put; 5exports.put = put;
5exports.get = get; 6exports.get = get;
6exports.del = del; 7exports.del = del;
@@ -92,6 +93,23 @@ function login(uri) {
92 }); 93 });
93} 94}
94 95
96function logout() {
97 checkConfig();
98
99 superagent.post(config.server() + '/api/logout').query(gQuery).end(function (error, result) {
100 if (result && result.statusCode !== 200) console.log('Failed to logout: ' + result.statusCode);
101 if (error) console.log(error);
102
103 // TODO remove at some point, this is just to clear the previous old version values
104 config.set('username', '');
105 config.set('password', '');
106 config.set('server', '');
107 config.set('accessToken', '');
108
109 console.log('Done'.green);
110 });
111}
112
95function put(filePath, otherFilePaths, options) { 113function put(filePath, otherFilePaths, options) {
96 checkConfig(); 114 checkConfig();
97 115
diff --git a/cli/surfer.js b/cli/surfer.js
index 46e5ba5..ef3ed91 100755
--- a/cli/surfer.js
+++ b/cli/surfer.js
@@ -11,6 +11,10 @@ program.command('login <url>')
11 .description('Login to server') 11 .description('Login to server')
12 .action(actions.login); 12 .action(actions.login);
13 13
14program.command('logout')
15 .description('Logout from server')
16 .action(actions.logout);
17
14program.command('put <file> [files...]') 18program.command('put <file> [files...]')
15 .option('-a --all', 'Also include hidden files and folders.', false) 19 .option('-a --all', 'Also include hidden files and folders.', false)
16 .description('Put a file, last argument is destination if provided') 20 .description('Put a file, last argument is destination if provided')