]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blob - cli/surfer.js
Make listen port and ldap filter more flexible
[perso/Immae/Projets/Nodejs/Surfer.git] / cli / surfer.js
1 #!/usr/bin/env node
2
3 'use strict';
4
5 var program = require('commander'),
6 actions = require('./actions');
7
8 program.version(require('../package.json').version);
9
10 // Those override the login settings if provided
11 program.option('-s, --server <url>', 'Server URL (optional)');
12 program.option('-t, --token <access token>', 'Server Access Token (optional)');
13
14 program.command('login <url>')
15 .description('Login to server')
16 .option('--username [username]', 'Username (optional)')
17 .option('--password [password]', 'Password (optional)')
18 .action(actions.login);
19
20 program.command('logout')
21 .description('Logout from server')
22 .action(actions.logout);
23
24 program.command('put <file|dir...>')
25 .option('-a --all', 'Also include hidden files and folders.', false)
26 .description('Puts a list of files or dirs to the destination. The last argument is destination dir')
27 .action(actions.put)
28 .on('--help', function() {
29 console.log();
30 console.log(' Examples:');
31 console.log();
32 console.log(' $ surfer put file.txt / # puts to /file.txt');
33 console.log(' $ surfer put file.txt /data # puts to /data/file.txt');
34 console.log(' $ surfer put dir /data # puts dir/* as /data/dir/*');
35 console.log(' $ surfer put dir/. / # puts dir/* as /app/data/*');
36 console.log(' $ surfer put dir1 dir2 file1 / # puts as /dir1/* /dir2/* and /file');
37 console.log();
38 });
39
40 program.command('get [file|dir]')
41 .description('Get a file or directory listing')
42 .action(actions.get);
43
44 program.command('del <file>')
45 .option('-r --recursive', 'Recursive delete directories.', false)
46 .option('-d --dry-run', 'Only list files to delete.', false)
47 .description('Delete a file or directory')
48 .action(actions.del);
49
50 program.parse(process.argv);
51
52 if (!process.argv.slice(2).length) {
53 program.outputHelp();
54 } else { // https://github.com/tj/commander.js/issues/338
55 // var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2]; });
56 // if (!knownCommand) {
57 // console.error('Unknown command: ' + process.argv[2]);
58 // process.exit(1);
59 // }
60 }