]>
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 | ||
8 | // Allow self signed certs! | |
9 | process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; | |
10 | ||
11 | program.version('0.1.0'); | |
12 | ||
32fbb54d | 13 | program.command('login <url>') |
8c3ae071 JZ |
14 | .description('Login to server') |
15 | .action(actions.login); | |
16 | ||
17 | program.command('put <file> [files...]') | |
eb83e4da | 18 | .option('-d --destination <folder>', 'Destination folder. This is prepended to the relative <file> path') |
d53a1669 | 19 | .option('-a --all', 'Also include hidden files and folders.', false) |
8c3ae071 JZ |
20 | .description('Put a file') |
21 | .action(actions.put); | |
22 | ||
7bb99aff | 23 | program.command('get [file]') |
8c3ae071 JZ |
24 | .description('Get a file or directory') |
25 | .action(actions.get); | |
26 | ||
27 | program.command('del') | |
28 | .description('Delete a file') | |
29 | .action(actions.del); | |
30 | ||
31 | program.parse(process.argv); | |
32 | ||
33 | if (!process.argv.slice(2).length) { | |
34 | program.outputHelp(); | |
35 | } else { // https://github.com/tj/commander.js/issues/338 | |
36 | var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2]; }); | |
37 | if (!knownCommand) { | |
38 | console.error('Unknown command: ' + process.argv[2]); | |
39 | process.exit(1); | |
40 | } | |
41 | } |