]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blame - cli/surfer.js
protect _admin/
[perso/Immae/Projets/Nodejs/Surfer.git] / cli / surfer.js
CommitLineData
8c3ae071
JZ
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
32fbb54d 13program.command('login <url>')
8c3ae071
JZ
14 .description('Login to server')
15 .action(actions.login);
16
17program.command('put <file> [files...]')
d53a1669 18 .option('-a --all', 'Also include hidden files and folders.', false)
c9d33e20 19 .description('Put a file, last argument is destination if provided')
8c3ae071
JZ
20 .action(actions.put);
21
7bb99aff 22program.command('get [file]')
24545229 23 .description('Get a file or directory listing')
8c3ae071
JZ
24 .action(actions.get);
25
24545229 26program.command('del <file>')
898fe7c8
JZ
27 .option('-r --recursive', 'Recursive delete directories.', false)
28 .option('-d --dry-run', 'Only list files to delete.', false)
24545229 29 .description('Delete a file or directory')
8c3ae071
JZ
30 .action(actions.del);
31
32program.parse(process.argv);
33
34if (!process.argv.slice(2).length) {
35 program.outputHelp();
36} else { // https://github.com/tj/commander.js/issues/338
37 var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2]; });
38 if (!knownCommand) {
39 console.error('Unknown command: ' + process.argv[2]);
40 process.exit(1);
41 }
42}