]>
Commit | Line | Data |
---|---|---|
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 | program.command('login <url>') | |
11 | .description('Login to server') | |
12 | .action(actions.login); | |
13 | ||
14 | program.command('logout') | |
15 | .description('Logout from server') | |
16 | .action(actions.logout); | |
17 | ||
18 | program.command('put <file> [files...]') | |
19 | .option('-a --all', 'Also include hidden files and folders.', false) | |
20 | .description('Put a file, last argument is destination if provided') | |
21 | .action(actions.put); | |
22 | ||
23 | program.command('get [file]') | |
24 | .description('Get a file or directory listing') | |
25 | .action(actions.get); | |
26 | ||
27 | program.command('del <file>') | |
28 | .option('-r --recursive', 'Recursive delete directories.', false) | |
29 | .option('-d --dry-run', 'Only list files to delete.', false) | |
30 | .description('Delete a file or directory') | |
31 | .action(actions.del); | |
32 | ||
33 | program.parse(process.argv); | |
34 | ||
35 | if (!process.argv.slice(2).length) { | |
36 | program.outputHelp(); | |
37 | } else { // https://github.com/tj/commander.js/issues/338 | |
38 | var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2]; }); | |
39 | if (!knownCommand) { | |
40 | console.error('Unknown command: ' + process.argv[2]); | |
41 | process.exit(1); | |
42 | } | |
43 | } |