]>
Commit | Line | Data |
---|---|---|
8c3ae071 JZ |
1 | #!/usr/bin/env node |
2 | ||
3 | 'use strict'; | |
4 | ||
5 | var program = require('commander'), | |
6 | actions = require('./actions'); | |
7 | ||
8fa08229 | 8 | program.version(require('../package.json').version); |
8c3ae071 | 9 | |
32fbb54d | 10 | program.command('login <url>') |
8c3ae071 | 11 | .description('Login to server') |
ff4aca50 JZ |
12 | .option('--username [username]', 'Username (optional)') |
13 | .option('--password [password]', 'Password (optional)') | |
8c3ae071 JZ |
14 | .action(actions.login); |
15 | ||
15397f71 JZ |
16 | program.command('logout') |
17 | .description('Logout from server') | |
18 | .action(actions.logout); | |
19 | ||
410ee66f | 20 | program.command('put <file|dir> [files...]') |
d53a1669 | 21 | .option('-a --all', 'Also include hidden files and folders.', false) |
c9d33e20 | 22 | .description('Put a file, last argument is destination if provided') |
8c3ae071 JZ |
23 | .action(actions.put); |
24 | ||
410ee66f | 25 | program.command('get [file|dir]') |
24545229 | 26 | .description('Get a file or directory listing') |
8c3ae071 JZ |
27 | .action(actions.get); |
28 | ||
24545229 | 29 | program.command('del <file>') |
898fe7c8 JZ |
30 | .option('-r --recursive', 'Recursive delete directories.', false) |
31 | .option('-d --dry-run', 'Only list files to delete.', false) | |
24545229 | 32 | .description('Delete a file or directory') |
8c3ae071 JZ |
33 | .action(actions.del); |
34 | ||
35 | program.parse(process.argv); | |
36 | ||
37 | if (!process.argv.slice(2).length) { | |
38 | program.outputHelp(); | |
39 | } else { // https://github.com/tj/commander.js/issues/338 | |
40 | var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2]; }); | |
41 | if (!knownCommand) { | |
42 | console.error('Unknown command: ' + process.argv[2]); | |
43 | process.exit(1); | |
44 | } | |
45 | } |