aboutsummaryrefslogtreecommitdiffhomepage
path: root/cli/surfer.js
diff options
context:
space:
mode:
Diffstat (limited to 'cli/surfer.js')
-rwxr-xr-xcli/surfer.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/cli/surfer.js b/cli/surfer.js
new file mode 100755
index 0000000..d906d62
--- /dev/null
+++ b/cli/surfer.js
@@ -0,0 +1,39 @@
1#!/usr/bin/env node
2
3'use strict';
4
5var program = require('commander'),
6 actions = require('./actions');
7
8// Allow self signed certs!
9process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
10
11program.version('0.1.0');
12
13program.command('login')
14 .description('Login to server')
15 .action(actions.login);
16
17program.command('put <file> [files...]')
18 .description('Put a file')
19 .action(actions.put);
20
21program.command('get')
22 .description('Get a file or directory')
23 .action(actions.get);
24
25program.command('del')
26 .description('Delete a file')
27 .action(actions.del);
28
29program.parse(process.argv);
30
31if (!process.argv.slice(2).length) {
32 program.outputHelp();
33} else { // https://github.com/tj/commander.js/issues/338
34 var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2]; });
35 if (!knownCommand) {
36 console.error('Unknown command: ' + process.argv[2]);
37 process.exit(1);
38 }
39}