]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blame - cli/surfer.js
Add --server and --token options to cli tool
[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
8fa08229 8program.version(require('../package.json').version);
8c3ae071 9
ec4c48f2
JZ
10// Those override the login settings if provided
11program.option('-s, --server <url>', 'Server URL (optional)');
12program.option('-t, --token <access token>', 'Server Access Token (optional)');
13
32fbb54d 14program.command('login <url>')
8c3ae071 15 .description('Login to server')
ff4aca50
JZ
16 .option('--username [username]', 'Username (optional)')
17 .option('--password [password]', 'Password (optional)')
8c3ae071
JZ
18 .action(actions.login);
19
15397f71
JZ
20program.command('logout')
21 .description('Logout from server')
22 .action(actions.logout);
23
410ee66f 24program.command('put <file|dir> [files...]')
d53a1669 25 .option('-a --all', 'Also include hidden files and folders.', false)
c9d33e20 26 .description('Put a file, last argument is destination if provided')
8c3ae071
JZ
27 .action(actions.put);
28
410ee66f 29program.command('get [file|dir]')
24545229 30 .description('Get a file or directory listing')
8c3ae071
JZ
31 .action(actions.get);
32
24545229 33program.command('del <file>')
898fe7c8
JZ
34 .option('-r --recursive', 'Recursive delete directories.', false)
35 .option('-d --dry-run', 'Only list files to delete.', false)
24545229 36 .description('Delete a file or directory')
8c3ae071
JZ
37 .action(actions.del);
38
39program.parse(process.argv);
40
41if (!process.argv.slice(2).length) {
42 program.outputHelp();
43} else { // https://github.com/tj/commander.js/issues/338
ec4c48f2
JZ
44 // var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2]; });
45 // if (!knownCommand) {
46 // console.error('Unknown command: ' + process.argv[2]);
47 // process.exit(1);
48 // }
8c3ae071 49}