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